Navigator.cookieEnabled

navigator.cookieEnabled 返回一个布尔值,来表示当前页面是否启用了 cookie。本属性为只读属性。

语法

let cookieEnabled = navigator.cookieEnabled;
  • cookieEnabled 是个布尔值truefalse

示例

if (!navigator.cookieEnabled) { 
  // 浏览器不支持 cookie,或者用户禁用了 cookie。
}

标准

标准 状态 备注
HTML Living Standard
Navigator.cookieEnabled
Living Standard 初次定义

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
cookieEnabledChrome Full support 1Edge Full support 12Firefox Full support 1
Notes
Full support 1
Notes
Notes Prior to 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.
IE Full support 4Opera Full support ≤12.1Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4
Notes
Full support 4
Notes
Notes Prior to 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.
Opera Android Full support ≤12.1Safari iOS Full support 1Samsung Internet Android Full support 1.0

Legend

Full support  
Full support
See implementation notes.
See implementation notes.