I'm trying to set a cookie for use across different virtual hosts. Something similar to this has been asked multiple times here:
Cookies in subdomain doesnt work
how to access cookies on subdomain
Setting cookies on domain/subdomain
cross subdomain login with cookies
They all mention a 'subdomain' but none describe what that is. If I have 2 Apache VHosts like so:
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/
...
</VirtualHost>
<VirtualHost *:80>
ServerName home.example.com
DocumentRoot /var/www/home/
...
</VirtualHost>
If I log the user in at example.com and set the --and make sure to say the next word in a deep cookie monster voice-- cookie like so
setcookie( 'id', '1234', time()+24*3600, '/', '.example.com' );
Can I get id
at home.example.com like so:
RewriteCond %{HTTP_COOKIE} \bid=[0-9]+\b
Or do these cross domain cookies only work when the subdomains are set up entirely within a single virtual host (presumably with mod_rewrite)