I added php_value session.cookie_domain .example.com to my .htaccess in order to be able to read PHP cookie from all subdomains, it seems to work however I cannot read the cookie when I am at: ‘example.com’ (no subdomains).
This is driving me crazy, I’m sure it’s a common issue since most people want their users to be logged in both the domain and all subdomains once they are authenticated.
What can I do to be able to write/read php cookie from any domain/subdomain?
There is no dependable way of doing this with session variables. You can either change your root domain to
www.example.comor use cookies.The docs for PHP’s setcookie say Cookies available to a lower domain, such as ‘example.com’ will be available to higher subdomains, such as ‘www.example.com’.