Page 1 of 1

setcookie prepending . to the cookie domain

Posted: Fri Apr 14, 2006 3:21 pm
by Nathaniel

Code: Select all

setcookie('test1', 'foo', time() + 3600, '/', 'www.yogler.com', 1);
setcookie('test2', 'bar', time() + 3600, '/', 'www.yogler.com');
setcookie('test3', 'foobar', time() + 3600, '/', '.yogler.com');
This may just be Firefox bugging up, but: 'test1' and 'test2' have the domain of '.www.yogler.com' (not a typo) when I go to Firefox's "View Cookies" button. 'test3' has the domain of '.yogler.com'.

The script setting these is on 'www.yogler.com' on an SSL link.

Does this seems to have something to do with them being set on an https:// page? Do I need to worry about it?

Posted: Fri Apr 14, 2006 3:23 pm
by feyd
the leading dot simply allows it to match all subdomains following the passed argument. In this case, the cookie would match blah.www.yogler.com, foo.www.yogler.com, etc..

Posted: Fri Apr 14, 2006 3:24 pm
by Nathaniel
Ok. Yay. Thanks.