Normally, when you use the setcookie() call in PHP, the domain is set
to whatever domain the user connected to the website with. No
problems unless you happen to change that domain for some reason.
(i.e. switch from using foo.com to www.foo.com) in which case you've
just lost all of your previous cookies.
To fix this particular nit, you can set cookies using the wildcard
domain .foo.com (the leading dot makes it match any subdomain of
foo.com)
However, if you still have cookies set with the domain: www.foo.com,
you'll now get two cookies coming back from the client browser, with
potentially conflicting values. Which one wins and winds up in
$_COOKIE appears to be undetermined but consistent. (i.e. if the
domain .foo.com wins on a particular page, it will always win on that
page, but on some other page www.foo.com will win)
My current hack/workaround is to unset all of the www.foo.com cookies
in every header. Does anybody know of a way to get access to the raw
headers in PHP so I could check if the www.foo.com cookies are set
first?
Rene