PHP Session does not access session variable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
panda
Forum Newbie
Posts: 5
Joined: Sat Nov 28, 2009 4:02 pm

PHP Session does not access session variable

Post 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
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Re: PHP Session does not access session variable

Post by daedalus__ »

check if session start failed on either page?
panda
Forum Newbie
Posts: 5
Joined: Sat Nov 28, 2009 4:02 pm

Re: PHP Session does not access session variable

Post by panda »

session starts on the all pages successfully
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Re: PHP Session does not access session variable

Post 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?
panda
Forum Newbie
Posts: 5
Joined: Sat Nov 28, 2009 4:02 pm

Re: PHP Session does not access session variable

Post by panda »

tried

var_dump($_session['memberId']);

it gives me

Undefined variable: _session
panda
Forum Newbie
Posts: 5
Joined: Sat Nov 28, 2009 4:02 pm

Re: PHP Session does not access session variable

Post by panda »

name of variable is same in both pages and am not using that register function
panda
Forum Newbie
Posts: 5
Joined: Sat Nov 28, 2009 4:02 pm

Re: PHP Session does not access session variable

Post by panda »

and in the previous page the value of member id is 1.. i checked using var dump
phoenixrises
Forum Newbie
Posts: 8
Joined: Sun Nov 15, 2009 8:24 am

Re: PHP Session does not access session variable

Post by phoenixrises »

Use $_SESSION. Afaik, superglobals are case sensitive.
Post Reply