1

How to detect that JavaScript and/or Cookies are disabled?

jQuery detecting cookies enabled

I tried both solutions, but IE still return true to me even if I set disabled to Cookies.

Please help.

Community
  • 1
  • 1
Ken
  • 487
  • 4
  • 9
  • Possible duplicate of [How to detect that JavaScript and/or Cookies are disabled?](http://stackoverflow.com/questions/4603289/how-to-detect-that-javascript-and-or-cookies-are-disabled) – Pineda Feb 14 '17 at 13:05
  • 1
    I once had a similiar problem. Found that if I opened files locally it won´t block cookies in IE11. – Tallerlei Feb 14 '17 at 13:08

1 Answers1

0

I used this:

function areCookiesEnabled() {
    try {
      document.cookie = 'cookietest=1';
      var cookiesEnabled = document.cookie.indexOf('cookietest=') !== -1;
      document.cookie = 'cookietest=1; expires=Thu, 01-Jan-1970 00:00:01 GMT';
      return cookiesEnabled;
    } catch (e) {
      return false;
    }
}

From Modernizr library

Zymotik
  • 6,412
  • 3
  • 39
  • 48