Navigator: cookieEnabled プロパティ

Baseline 2024
Newly available

Since September 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

navigator.cookieEnabled は、クッキーが有効かどうかを示す論理値を返します。

このプロパティは読み取り専用です。

論理値です。

メモ: ブラウザーがサードパーティのクッキーをブロックするように構成されていた場合で、 navigator.cookieEnabled がサードパーティの iframe の中で呼び出された場合、 Safari, Edge Spartan, IE では true を返します (この場合にクッキーを設定しようとしても失敗するにもかかわらず)。 Firefox および Chromium ベースのブラウザーでは false を返します。

メモ: ウェブブラウザーは特定の場面で特定のクッキーを書き込むことを阻止することがあります。例えば、 Chrome ベースのブラウザーや、 Firefox の一部の実験的なバージョンでは、 SameSite=None 属性の付いたクッキーを作成することを許可しませんが、 HTTPS 上で生成され Secure 属性がある場合は例外です。

js
if (!navigator.cookieEnabled) {
  // ブラウザーが対応していないか、クッキーが設定されることをブロックしています。
}

仕様書

Specification
HTML
# dom-navigator-cookieenabled-dev

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
cookieEnabled

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support
See implementation notes.
Has more compatibility info.