I have a dev server in our office that is behind the firewall. The hostname is franklin. We name all our servers after scientists or inventors.
When I set an HTTP cookie:
Set-Cookie: user=kenny; expires=1245424860.11; Path=/; domain=franklin
The cookie doesn't set. I have tried the following with no luck.
.franklin
.franklin.local
franklin.local
.franklin.localdomain
franklin.localdomain
Do I have to set the hostname to something different or can I set this cookie through some magic I don't know already?
Are you setting the cookie from the right domain? You should access the website over http://franklin/ otherwise it wouldn't work (see: same origin policy).
RFC 2109 says:
And also:
If your host is
franklin
:domain=.franklin
will be rejected, because it has no embedded dot.domain=.franklin.local
will be rejected, because it does not match the actual host name of your server.The solution is to rename your hostname to
franklin.local
orfranklin.<tld>
and set thedomain
attribute of the cookie accordingly (domain=.franklin.<tld>
). Alternatively (as you found out), do not specify thedomain
, and let the user agent fallback to the request host.