0

Required to show an alert when cookies are disabled in IE browser, used the below code

var cookieEnabled = (navigator.cookieEnabled) ? true : false;

if (typeof navigator.cookieEnabled == "undefined" && !cookieEnabled) {
    document.cookie = "testcookie";
    cookieEnabled = (document.cookie.indexOf("testcookie") != -1) ? true : false;
}
// navigator.cookieEnabled == true
if (cookieEnabled == false)
    alert();

but even the cookies are enabled or disabled in IE always getting true (cookies enable) only, any solution to handle this.

Thanks in Advance

loelsonk
  • 3,570
  • 2
  • 16
  • 23
SunilKumar
  • 11
  • 2
  • 1
    yeah, because you set `document.cookie` and check if `document.cookie` exists, which will always be the case, because you set it.. – giorgio Jul 02 '18 at 16:14
  • https://stackoverflow.com/questions/4603289/how-to-detect-that-javascript-and-or-cookies-are-disabled – epascarello Jul 02 '18 at 16:16
  • 2
    Possible duplicate of [How to detect that JavaScript and/or Cookies are disabled?](https://stackoverflow.com/questions/4603289/how-to-detect-that-javascript-and-or-cookies-are-disabled) – Jack Jul 02 '18 at 16:23
  • Hi Jack thanks for the reply, I checked the link and try to implement based on the reference provided but still even at the cookie enabled or disabled both the condition it was getting the true condition. Need only at the time of cookies disabled. – SunilKumar Jul 02 '18 at 16:29

0 Answers0