Jump to content

[SOLVED] Global Sessions?


Errant_Shadow

Recommended Posts

Well, I've found a few methods to do this...

 

The php.ini configuration contains a line that, by default, is blank; your server fills this in with your full domain name when a session is created. Unfortunately, that includes the subdomain, thus limiting that session to ONLY that subdomain.

 

To fix this you can either open the php.ini and change it to read as:

 

"session.cookie_domain = .yourdomain.com"

 

(the dot separator there at the beginning is important for cross-browser compatibility)

 

Or, if you can't, or don't want to access the php.ini file, you can use the ini_set method to do pretty much the same thing:

 

ini_set('session.cookie_domain', substr($_SERVER['SERVER_NAME'],strpos($_SERVER['SERVER_NAME'],"."),100));

 

And this can be included in an init file that should be included in every page; or it can be included by itself and it appears to run fine.

 

Alternatively, you can use the session_set_cookie_params() method before every call to session_start(). The parameters available include int $lifetime  [, string $path  [, string $domain  [, bool $secure = false  [, bool $httponly = false  ]]]]. The brackets mean that in order to set the domain, you must first set the life time and the path (in that order); keeping in mind that the default life time is zero (0) and the default path is "/".

 

So this method would read:

 

session_set_cookie_params(0, "/", ".yourdomain.com")

Now, while that solved the question here (thus solving the thread) it did not fix my problem...

 

So if anyone would like to continue helping me to find a solution to my rather persistent bug, I've made a new thread: The Indestructable Session

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.