Jump to content

My session variable disappears :(


mads

Recommended Posts

I have no idea why, but sometimes my session variable disappears. After having stared at it for two days, I guess it's time to cry for help...

 

This is how I set the variable and later try to use it again:

 

1) I'm creating a session in header.php (a file that is loaded everytime a webpage is displayed):

session_start();

...

$_SESSION['displaymode'] = "abe";

 

2) I'm using the variable in go.php (which does not load header.php when it is displayed):

session_start();

...

if(isset($_SESSION['displaymode']))

{

    $displaymode = $_SESSION['displaymode'];

}

 

Can anyone see why my session variable disappears? isset() returns false approx. 50% of the time and I have absolutely no idea why :(

 

Thanks a lot,

Mads

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/165894-my-session-variable-disappears/
Share on other sites

That didn't help :(

 

I added session_save_path("mysessions") right before session_start() in header.php. Afterwards, I can see the session files being created in the "mysessions" directory on the webserver, but the session variable still doesn't exist when I need it in go.php

 

Any other ideas on what might be going wrong?

 

Thanks again,

Mads

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.