Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.