How well supported is navigator.cookieEnabled? Can I safely rely on it for all browsers?
How well supported is navigator.cookieEnabled ? Can I safely rely on it for all
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I know it’s present in at least IE 6 and later, Firefox 1 and later, and Dottoro reports that it is supported by all major browsers. However, it is not part of any DOM specification and therefore is not guaranteed to be available in or properly implemented by all browsers (for instance, mobile browsers with limited DOM implementations).
As some have discovered, IE returns true for
navigator.cookieEnabledeven if cookies are blocked for the current site. This means that you cannot currently rely on the property at all and you should avoid it completely.For a complete cross browser cookie support check, you might want to go with something like this:
Demo: http://codetester.org/31011785
This will return
falsein browsers that have cookies disabled or don’t support the DOM level 2 propertydocument.cookie, which is about as far as you can go in JS.