Reputation: 157
I haven't been able to get a document.cookie to successfully create using IE11.
The following test code works in FF, Chrome and Safari. This is the only code that's in the test file:
function isCookie() {
document.cookie = "testcookie";
var cookieEnabled = (document.cookie.indexOf("testcookie") != -1) ? true
: false;
alert(cookieEnabled); //alert true
alert(document.cookie.indexOf("testcookie")); //alert 0
alert(document.cookie); //alert testcookie
return (cookieEnabled);
}
isCookie();
I have a Mac and used IE11 via VirtualBox to test as well as a separate Windows 7 laptop. In both cases, the alert messages above are 'false' and '-1' only in IE.
I checked the IE security settings and have Protected mode off and changed Security to accept cookies from all sites. Restarted IE after the changes, and still I can't get document cookie to write.
I'm looking in Local\Microsoft\Windows\Temporary Internet Files. I see some cookies already in there from other sites, but not 'testcookie' from the test above.
Any ideas?
Upvotes: 3
Views: 2768
Reputation: 157
I hope this saves someone the time I spent on this problem.
The issue was that Microsoft does not allow cookies to be written when the URL has an underscore in it. Yep.
I confirmed this by changing our staging URL to use a '-' instead of '_' and cookies are now be written and read successfully in IE.
An article about this issue: https://ma.ttias.be/internet-explorer-wont-allow-cookies-subdomains-underscores/
Upvotes: 3