Cipiripi
Cipiripi

Reputation: 1143

Set domain for cookie (localhost) in IE

I need to set cookie's domain for localhost and I'm using internet explorer. I tried:

Response.Cookies["MyCookie"].Domain = ".local";   

but it didn't work, because cookies value and domain are later set to null. Any idea? Thanks

Upvotes: 0

Views: 1114

Answers (1)

home
home

Reputation: 12538

I suppose this question is related to your local development environment. localhost does not map to the local domain, e.g. pinging localhost.local should not work.

In Windows environments I successfully worked with domain cookies by updating the hosts file with a statement like this:

127.0.0.1   localhost    localhost.domain.com

Now you can point your browser to localhost.domain.com and set the cookie's domain property to domain.com. You may need to make this FQDN available to your runtime (in e.g. Tomcat it worked out of the box).

Upvotes: 1

Related Questions