I need to share a session between two subdomains.
I have these domains:
http://example.com
https://secure.example.com
And I tried session sharing with this way:
<?php ini_set("session.cookie_domain", ".example.com"); session_start(); ?>
And this also
<?php session_set_cookie_params ( 0,"/" ,".example.com"); session_start(); ?>
But both seems not working!
How can I make it works?
Sorry for bad English
I don't think sessions are shared across sub-domains. Instead assign the value of the session to a cookie. The cookies are shared.
setcookie("TestCookie", $value, time()+3600);
get the value of the cookie by using this:
$_COOKIE['TestCookie'];
Solved.
I created .htaccess file with this content:
php_value session.cookie_domain ".example.com"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.