Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.


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

share|improve this question

1 Answer 1

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);

share|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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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