Checking if cookies are enabled doesn't work in IE8
- by the_V
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?