Checking if cookies are enabled doesn't work in IE8
Posted
by the_V
on Stack Overflow
See other posts from Stack Overflow
or by the_V
Published on 2010-06-02T20:09:50Z
Indexed on
2010/06/02
20:14 UTC
Read the original article
Hit count: 165
JavaScript
|cookies
Hi,
I'm trying to create a script that would determine if cookies are enabled and do some work if not. This is the code I use:
var cookieEnabled = (window.navigator.cookieEnabled) ? true : false;
if (typeof navigator.cookieEnabled == "undefined" && !cookieEnabled) {
document.cookie = "testcookie"
cookieEnabled = (document.cookie.indexOf("testcookie") != -1) ? true : false
}
if (cookieEnabled == false) {
// do some work
}
The problem is that in IE8 it causes nothing to happen when I set cookies to be blocked in browser options. So, navigator.cookieEnabled is always true. This stuff works perfectly in Chrome and FireFox. Am I doing anything wrong?
© Stack Overflow or respective owner