Page 1 of 1

PHP Session does not access session variable

Posted: Sat Nov 28, 2009 5:54 pm
by panda
<?php
session_start();
if ( !isset($_session['memberId']))
{
header( 'Location: http://google.com' ) ;
}
else
{
//Blah blah
}

In the previous page i have set the member Id but here it cannot view as the page always redirects to google

please help me

Re: PHP Session does not access session variable

Posted: Sat Nov 28, 2009 7:13 pm
by daedalus__
check if session start failed on either page?

Re: PHP Session does not access session variable

Posted: Sat Nov 28, 2009 8:52 pm
by panda
session starts on the all pages successfully

Re: PHP Session does not access session variable

Posted: Sat Nov 28, 2009 9:17 pm
by daedalus__
take out that redirect and get_defined_vars() or var_dump() or something.

what's the code on the other page look like? are you asking for the same variable on both pages? sometimes ill change the name of something and forget it is referenced in other files..

might you be using session_register() for some strange reason?

Re: PHP Session does not access session variable

Posted: Sat Nov 28, 2009 9:38 pm
by panda
tried

var_dump($_session['memberId']);

it gives me

Undefined variable: _session

Re: PHP Session does not access session variable

Posted: Sat Nov 28, 2009 9:40 pm
by panda
name of variable is same in both pages and am not using that register function

Re: PHP Session does not access session variable

Posted: Sat Nov 28, 2009 9:47 pm
by panda
and in the previous page the value of member id is 1.. i checked using var dump

Re: PHP Session does not access session variable

Posted: Sun Nov 29, 2009 3:43 am
by phoenixrises
Use $_SESSION. Afaik, superglobals are case sensitive.