Internet Explorer 11 won't set cookies on a site

36,208

Solution 1

IE 11 does not like a domain value in the cookie. Leave it empty.

Wrong for IE 11:

Set-Cookie: kohanasession=foobar; expires=Tue, 09-Apr-2016 01:01:01 GMT; path=/; domain=tc.mk; httponly

Correct for IE 11:

Set-Cookie: kohanasession=foobar; expires=Tue, 09-Apr-2016 01:01:01 GMT; path=/; httponly

Solution 2

This may only apply to another-domain cookies, but if someone finds this via Google (like I did) this may help.

IE11 may not set cookies depending on its Privacy settings.

This worked for me:

enter image description here

(Internet Options -> Privacy -> Advanced -> enable all cookie cases there)

Solution 3

I know this is old, but hopefully this helps someone in the future. You cannot have a blank expires=; value in a cookie in IE11. You just have to leave the expires field out altogether.

Solution 4

I had this issue because I was running a single-page Vue application. I was setting the cookie in one route, then immediately routing to a different "page". However, it seems like IE won't send cookies until next page load. So instead of using pushState, I had to force the browser to re-load the page.

Solution 5

I recently had this problem myself. In my case, the problem was caused by executing the "ClearAuthenticationCache" command upon successful login. The command was executed to remove HTTP authentication, but it turns out that it will remove session cookies as well.

So I would recommend removing the "ClearAuthenticationCache" call if you executing it after a login.

document.execCommand("ClearAuthenticationCache");

For more information, please see the following link: https://blogs.msdn.microsoft.com/ieinternals/2010/04/04/understanding-session-lifetime/

Share:
36,208

Related videos on Youtube

prototype
Author by

prototype

Web Developer | Web Designer | Ubuntu 12.04 User | South Park fan | Star Wars fan

Updated on July 09, 2022

Comments

  • prototype
    prototype almost 2 years

    For some reason IE11 (only IE11, tested with other IE9 and IE10) won't create a session on a site i've been working on. So this means that a basic functionality such as site login won't work.

    On other browsers this is working perfectly.

    I researched a bit and found out that IE won't work with domains with underscore.. but my domain doesn't have one so what could be the problem? Thanks!

    • 1DMF
      1DMF over 9 years
      Did you find a resolve? I am experiencing the same problem with a member who's IE11 on Win 8 refuses to accept the session cookie,
    • prototype
      prototype over 9 years
      I haven't found a solution..
    • 1DMF
      1DMF over 9 years
      I've added the domain to trusted sites, I've forced acceptance of cookies through the security settings, I've reset the browser, deleted all data, but still IE11 refuses to accept the session cookie. Google Chrome works fine as does FireFox, but IE won't budge.
    • Atherion
      Atherion almost 9 years
      I too am having this problem, already 2 users stating they can't login to my site. Whats going one, I think there is a bug somewhere.
    • Colin R. Turner
      Colin R. Turner almost 7 years
      Did we find an answer to this problem? I have the same problem. Tried removing domain attribute and no difference.
    • Chrissi
      Chrissi almost 6 years
      Underscore is not an allowed domain name character according to RFC1035. As such, the hint you've found that IE is not working with one is ... bizarre.
  • bebbo
    bebbo almost 7 years
    @freeworlder can you be more specific? Maybe you have multiple errors in your cookie setting code.
  • Matt Montag
    Matt Montag over 6 years
    Hi @bebbo, do you have a reference to verify your claim?
  • bebbo
    bebbo over 6 years
    @Matt: it solved the problem in the project I was working.
  • Tushar
    Tushar almost 6 years
    @bebbo After searching a lot I found this answer and finally this solution worked. Thank you man!
  • leiavoia
    leiavoia over 5 years
    More info: IE11 does accept a domain but it does not accept domains of localhost or machine names without a TLD like http://myservername/. It also apparently chokes on subdomains with underscores. See: weblog.west-wind.com/posts/2012/Apr/25/…
  • arif.khan.b
    arif.khan.b almost 4 years
    I was struggling to figure out the issue with angular code. Your suggestion helped me resolve this issue thanks
  • s.meijer
    s.meijer over 3 years
    Thanks @leiavoia! That's it! This had me while debugging an issue on localhost. Adding 127.0.0.1 home.local to /etc/hosts and using that domain instead, fixed my issues.