开发者

Subdomain Session Issue

开发者 https://www.devze.com 2023-02-20 10:58 出处:网络
I am trying to access session data across multiple wildcard sub domains. I set the session using the following:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消