navigator.cookieEnabled
returns a Boolean value that indicates whether cookies are enabled or not.
The property is read-only.
navigator.cookieEnabled
returns a Boolean value that indicates whether cookies are enabled or not.
The property is read-only.
A boolean.
Note: When the browser is configured to block third-party cookies, and navigator.cookieEnabled
is invoked inside a third-party iframe, it returns true
in Safari, Edge Spartan and IE (while trying to set a cookie in such scenario would fail). It returns false
in Firefox and Chromium-based browsers.
Note: Web browsers may prevent writing certain cookies in certain scenarios. For example, Chrome-based browsers, as well as some experimental version of Firefox, does not allow creating cookies with SameSite=None
attribute, unless they are created over HTTPS and with Secure
attribute.
js
if (!navigator.cookieEnabled) { // The browser does not support or is blocking cookies from being set. }
Specification |
---|
HTML Standard # dom-navigator-cookieenabled-dev |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
cookieEnabled |
1 | 12 | 1Before Firefox 8,navigator.cookieEnabled would report the wrong result if a site exception was in place for the page on which the check was performed. This has been fixed. |
4navigator.cookieEnabled returns true even if the browser is set to block cookies (for example, if the page is in the Restricted sites security zone). |
≤12.1 | 1 | 4.4 | 18 | 4Before Firefox 8,navigator.cookieEnabled would report the wrong result if a site exception was in place for the page on which the check was performed. This has been fixed. |
≤12.1 | 1 | 1.0 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Navigator/cookieEnabled