Session Management across subdomains


I’m having trouble getting PHP sessions to propagate across subdomains. At this time, I currently have three subdomains, two of which are connected to a Dreamhost MySQLi database for user login. My hope for this website was I could have a subdomain that manages user authentication, with other subdomains having other specific functions (which require authentication).

The problem I’m facing is that $_SESSION data are not being saved across subdomains, even though I’ve got php_value session.cookie_domain in my .htaccess on both sites, and both websites have the same cookie. On the authentication site, the data appear normally, but on the other site, performing var_dump($_SESSION) shows a blank array. As a novice to web hosting, how is it possible for $_SESSION data to be shared across subdomains? Is this a Dreamhost problem; if so how can I fix it without transitioning to a dedicated VPS?

Have you tried generating a unique id?

Save that id into session storage…but only the first time, when there is no value already in the session storage. Then migrate that id to data in the cross domain local storage.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.