I have a domain and a subdomain which I need both to recognise a cookie set by the main domain. On http://www.mydomain.com I set the cookie with Javascript like so:
var d = new Date();
d.setDate(d.getDate() + 30);
var c = "all; expires=" + d.toUTCString() + "; path=/;domain=mydomain.com";
document.cookie = "cookies=" + c;
In the PHP I use a simple if (isset($_COOKIE['cookies'])) ... This works on http://www.mydomain.com but it doesn’t work on sub.mydomain.com.
Any suggestions? Do I have to call the cookie within PHP differently?
1 Answer