Morvael
Morvael

Reputation: 3567

IE 10 not setting / sending cookies (from js) to server

A while back I switched a large development project from using cookies to using localStorage. However I've realized that I was a little bit gun-ho and that some of the cookies were actually need on the server.

I have set these back from localStorage to using cookies. However in the interim I have installed IE10 on my Win7 dev box and also switched my development server from IIS Express to ISS 7.5 running locally.

To allow Fiddler to intercept my local traffic I access the development pages through the URL

http://local_iis/ 

which is identified in the Hosts file as:

local_iis 127.0.0.1

However IE10 fails to set Cookies when accessing pages from this domain with this test page:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript">
        document.cookie = "test=value";
        alert(document.cookie); // gives "" in IE 10
    </script>
</head>
<body>

</body>
</html>

However running my test page from either of the below sets the cookie (and alerts the value)

http://localhost/
http://127.0.0.1/    

The cookie gets set and alerted correctly in both FF and Chrome, as I only ever use IE for development and testing I have changed the security settings down to allow everything in both the Privacy tab, and Local Intranet and Trusted Sites zones under the security tab. I've added local_iis to the trusted sites as well.

Still no cookie being set.

Does anyone know why?

Upvotes: 2

Views: 4473

Answers (1)

Andrew Haritonkin
Andrew Haritonkin

Reputation: 193

According to another topic found here and follow up of mentioned MS blog there this happens because you have underscore in the name of your machine! Wicked, huh?

See this:

Q5: IE won’t set a cookie when the hostname/domain contains an underscore?

A: Correct. Technically, underscore is not a DNS character, and while Windows will let you use an underscore when naming your machine, it warns you that doing so may cause problems. One such problem is that WinINET blocks attempts to set cookies on such domains.

Upvotes: 7

Related Questions