Situation:
- I’m trying run an https store (xcart) under one domain secure.example.com and I want to have access to a cookie it sets in http http://www.example.com
- I’m running PHP on Apache (MAMP), testing in Firefox with Firecookie
- The existing code sets cookies to
.secure.example.com. I’m not sure if this is xcart related, butsetcookieis actually called usingsecure.example.com. I’m not sure why the “.” is appended.
Problems:
-
When I try to use
setcookiein https to use the domain.example.comor justexample.com, no cookie is created, whether I’m running the store under http or https. The testing code I’m using is:setcookie('three', 'two', 0, "/", ".example.com");
If I set the cookie to secure.example.com or .secure.example.com it does show up.
Is there a reason the cookie isn’t showing up?
The problem was that I was using localhost with a one word domain, ‘mydomain’, a fact which for some reason was edited out of the original message. At least firefox requires at least two words for an explicitly set cookie, something like mydomain.local. I changed the hosts file to have the domains: http://www.mydomain.local and secure.mydomain.local, and I was able to set the cookies to .mydomain.local.
Also I found that php automatically puts a “.” in front of explicitly set cookies.