子域会话问题 [英] 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;
?>
我在 sub1.example.com $上设置了上述会话c $ c>。然后,我转到
sub2.example.com
并使用以下代码访问会话:
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?
推荐答案
您是否尝试过使用以下方法:
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
这篇关于子域会话问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文