php $_SESSION variables disappearing

Lord-Nikon

Expert Member
Joined
Jul 22, 2008
Messages
2,511
Reaction score
0
I'm creating global variables using the $_SESSION super global. The problem I'm having is when jumping between pages my variable seems to disappear.

Ex. I'm creating the variable on pageA.php, then I call it in pageB.php and it's there but it seems to disappear in pageA.php and is no longer visible in pageB.php after refresh nor is it visible in pageC.php after pageB.php has called upon it...

What on earth could the problem be? Or a work around this problem?
 
I can't remember all of that (Dreamweaver FTW) but since your cookies-> rvariables disappear, it seems they are flushed at close()... have you set any such settings or code to do that?
You should by default be able to call a variable within 20 minutes from it being created.
 
Do you have automatic session starting set in your config? What session backend are you using?
 
I'm using no session_destroy(); function and thats what's bothering me. The variables (globals) disappear in a matter of seconds! Not even minutes!
 
Do you have automatic session starting set in your config? What session backend are you using?

Apache web server is suppose to handle my sessions? Is that what you mean?

EDIT: I need to call a function : session_start(); at the beginning of all the pages I want to use the $_SESSION variable and it seems to work until you call it more then once from different pages...
 
PHP has different session storage mechanisms if I recall correctly.

session_start is meant to be called before accessing any session variable on each page the user will browse to, unless sessions are set to auto-start in the php.ini file for your server.

Also check the lifetime that is being set for the sessions you create.

Try doing a phpinfo() on a test page and see what it says your settings are.
 
tx icyrus, I have already browsed through my php.ini file, my session auto start is disabled, hence me calling the session_start() function... I'm quickly going to open phpinfo() and check if my variables are listed there...
 
Top
Sign up to the MyBroadband newsletter
X