I've written a cookie for my domain + subdomain:

setcookie("visitor", $visitor, time()+60*60*24*365, "/", ".mydomain.net");

but when I try to read it from within subdomain.mydomain.net, it's empty. Could it be that $_COOKIE[] tries to read the cookie for the subdomain instead of reading the global one? How do I fix this?
TIA
Steven

Edit
Happens in both Firefox and IE8

link|improve this question
feedback

1 Answer

You should check in your browser if the cookie actually exists for .mydomain.net (be sure the www part is excluded).

If that's the case then you should be able to read it from any .mydomain.net sub-domain using $_COOKIE['visitor'] in PHP.

Just in case try dumping the $_COOKIE data by doing print_r($_COOKIE);

link|improve this answer
Grazie della risposta! The cookie exists alright; it is correctly read on the pages of mydomain.net. – stevenvh Aug 22 '10 at 14:36
@stevenvh: Prego :) . Is there a cookies set for 'visitor' on subdomain.mydomain.net? This would overwrite the 'visitor' on .mydomain.net – Luca Matteis Aug 22 '10 at 14:43
no (inglese: "no" ;-)), there are no cookies except the global one. – stevenvh Aug 22 '10 at 15:50
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.