Subdomain Session Issue
I am trying to access session data across multiple wildcard sub domains. I set the session using the following:
<?php
session_name("session");
session_set_cookie_params(0, '/', '.example.com');
session_start();
$_SESSION['mID'] = 192;
?>
I set the above sess开发者_如何学JAVAion while on sub1.example.com
. I then go to sub2.example.com
and use the following code to access the session:
<?php
session_name("session");
session_set_cookie_params(0, '/', '.example.com');
session_start();
print_r($_SESSION);
?>
But the session is empty. What am I missing?
Have you tried using:
session_regenerate_id(true);
Worked for me when I have this problem.
http://php.net/manual/en/function.session-regenerate-id.php
精彩评论