jQuery: Problems cookies internet explorer
Posted
by
user1140479
on Stack Overflow
See other posts from Stack Overflow
or by user1140479
Published on 2012-12-16T07:47:42Z
Indexed on
2012/12/16
11:05 UTC
Read the original article
Hit count: 154
I have made a login page. When the user logs in a request to an API is send. This API is PHP and checks the username and password. When both are correct an unique key is send back (this is placed in the database for further use: userid and other stuff needed in the website). After that key is sent back it is placed in a cookie:
$.cookie("session", JSON.stringify(result));
After the cookie is set I send the user to a new page:
location.href = 'dashboard.htm';
In this page jQuery checks if the cookie "session" is present. If not, the user is send back to the login page.
sessionId = ($.cookie("session") ? JSON.parse($.cookie("session")).SessionId : 0);
return sessionId;
This works fine in Chrome, but IE (8/9) has some problems with this. I figured out that when you get to dashboard.htm the session is present. As soon as I hit F5 the session is gone. And sometimes the cookie isn't set at all!
I can't seem to figure out why this is happening in IE. Has someone any idea? Other options/ideas to save that unique key are also welcome.
Thanks in advance.
© Stack Overflow or respective owner