Jump to content

Change directory --> Lose session values


tekrscom

Recommended Posts

Hi, I have been searching around for a solution for how to not lose my session values when changing directories and it seems to have to do with the location in which the session information is stored... From what I can tell, when I change to a different directory, I need to somehow tell it the proper location. e.g. As long as I stay in the main directory, e.g. www/somepage.php, everything works fine, but as soon as I go to another directory, e.g. www/another_directory/somepage.php, I no longer have any session values... However, if I return to the main directory, there they are again, still in tact.

 

EDIT: I just discovered that, it only loses the values on the navigation menu, which is located in the main directory, being called by the page that is in the different directory, not in the page that is located in the different directory.

Link to comment
https://forums.phpfreaks.com/topic/55461-change-directory-lose-session-values/
Share on other sites

I think you can do this:

 

When you set the session variables upon login or where do the following:

 

session_set_cookie_params(0,"/","domain.com");

$_SESSION['session.cookie_domain'] = "domain.com";

 

That makes the sessions available on all subdomains and such.  You can look up the parameters to make them more catered to what you need.

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.