This is a space that holds a collection of my personal work and ideas

IE Won't Set Cookie

Posted on 11/13/2018

This article shares a different behavior in IE than Chrome when expecting to set a cookie.

I have a client app that using javascript to set the cookie for URL: http://localhost/login

The code looks like this:

var c = "_s=" + sessionId + ";path='/';max-age=36000";
document.cookie = c;
console.log("c", c);
console.log("Cookie", document.cookie);

In chrome, it prints out:

c _s=1b022d51-00c3-4a40-a105-35c638986354;path='/';max-age=36000
Cookie _s=1b022d51-00c3-4a40-a105-35c638986354

But in IE (11 or edge 17)

It prints out:

c _s=1b022d51-00c3-4a40-a105-35c638986354;path='/';max-age=36000
Cookie 

I have enabled setting cookie option in the internet option, but still got nothing back after setting the cookie.

It turns out IE doesn't like the quotes around the path option, while other browsers aren't that picky.

Remove the quote resolves the problem.

Read on GitHub