setcookie prepending . to the cookie domain

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Nathaniel
Forum Contributor
Posts: 396
Joined: Wed Aug 31, 2005 5:58 pm
Location: Arkansas, USA

setcookie prepending . to the cookie domain

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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..
User avatar
Nathaniel
Forum Contributor
Posts: 396
Joined: Wed Aug 31, 2005 5:58 pm
Location: Arkansas, USA

Post by Nathaniel »

Ok. Yay. Thanks.
Post Reply