Possible Duplicate:
PHP Sessions across sub domains
I can't seem to get this to work. I want to be able to log in 开发者_运维百科from my main domain, and remain logged in when they go to a subdomain of the site. Whenever I go from my main domain to a subdomain, I'm immediately logged out.
I've tried changing session.cookie_domain in php.ini with no avail, as well as trying
ini_set('session.cookie_domain','.site.com' );
and this in .htaccess as well
php_value session.cookie_domain .site.com
How can I have sessions go between subdomains?
- stick with ini_set(); or, even better, with session_set_cookie_params()
2. debug your code
- verify your settings, if they actually were set, by outputting them
- verify actual HTTP headers sent by your server to the client.
- verify actual HTTP headers sent by your browser to the server.
Sessions are not a black box; it's just a combination of a few very simple mechanisms such as HTTP cookies, so check every part of it.
精彩评论