Subdomain Session Issue

Deadly 提交于 2020-02-02 11:16:51

问题


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 session 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?


回答1:


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



来源:https://stackoverflow.com/questions/5458559/subdomain-session-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!