PHP Session Cookies Across Subdomains and Multiple Domains
I was looking into how to make sessions work across multiple subdomains and found this post to be most helpful.
So you need to change the php session configuration option for session.cookie_domain from the default of “” (which inserts your hostname) to:
You can do this with: session_set_cookie_params() before doing your session_start() or if you have php start your sessions for you automatically you might consider throwing:
php_value session.cookie_domain ".domain.com"into the .htaccess file for the site. If you put the .htaccess file in the directory for xxx.domain.com then all sessions started on xxx.domain.com will be shared on all other domains like www.domain.com. This means however that sessions started in www.domain.com won’t carry over unless the .htaccess file is also present in it’s root directory.
The first dot in “.domain.com” is not always nessesary however for support of all browsers it is suggested.