I tried to maintain session vars between two subdomains and found this impossible. I ended up creating 2 minimal PHP web pages as a test bed, which I call "test 1", just sets
$_SESSION['test'] = "Fred";
and has a hyperlink to 'test 2', which just tries to display the value of $ _SESSION ['test'] to prove that it worked or not. I put 'test 1' in my www domain and 'test 2' in my subdomain. I am trying a different version of what should be in the header from different sources. Here are the main 3 (and, of course, their options):
ini_set('session.cookie_domain',substr($_SERVER['SERVER_NAME'],strpos($_SERVER['SERVER_NAME'],"."),100)); session_start();
or
ini_set('session.cookie_domain','mydomain.com'); session_start();
or
ini_set('session.cookie_domain', PHP_INI_ALL); session_start();
or
session_set_cookie_params(0, "/", ".mydomain.com", false); session_start();
I find that I get the same result in every case. The session is not migrated through subdomains, and page 2 verification has no idea what value I set $ _SESSION ['test']. Nevertheless, there seems to be a lot of certainty that one of the above methods should work. Any idea what might happen, especially since I use minimal pages to test the mechanism (no side effects that I can see)? By the way, I'm on a shared server if this pertinant is here.
Thanks for your thoughts. Franc.
Edit I fixed it. The problem was caused by Sukhosin. See the detailed answer at the end of this page.
php session-cookies subdomain session-variables
Frankie
source share