JavaScript Navigator cookieEnabled Property

Beginner
⏱️ 8 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Baseline

What You’ll Learn

navigator.cookieEnabled is a read-only Boolean that tells you whether cookies are enabled. Learn the MDN check pattern, UI messaging, limits of the flag, five examples, and try-it labs.

01

Kind

Read-only property

02

Returns

Boolean

03

Baseline

Newly available

04

true

Cookies enabled

05

false

Blocked / unsupported

06

Use

Quick capability check

Introduction

Many sites use cookies for sessions, preferences, and consent. If the user (or browser) blocks cookies, features that depend on them can fail in confusing ways.

navigator.cookieEnabled gives you a simple Boolean answer: are cookies enabled right now? MDN: when it is false, the browser does not support cookies or is blocking them from being set.

💡
High-level flag

true does not mean every cookie attribute combination will succeed. Special cases (for example SameSite=None without HTTPS + Secure) can still be rejected.

Understanding the cookieEnabled Property

Think of cookieEnabled as a traffic light for cookie storage at the browser level. You read it once (or when you need to warn the user) — you never assign to it.

  • true — cookies appear enabled for normal use.
  • false — cookies unsupported or blocked — show a clear message.
  • Read-only — part of the HTML Navigator interface.
  • Baseline — Newly available across modern browsers (MDN, since Sept 2024).

📝 Syntax

General form of the property:

JavaScript
navigator.cookieEnabled

Value

  • A Boolean indicating whether cookies are enabled.

Common patterns

JavaScript
// MDN pattern:
if (!navigator.cookieEnabled) {
  // The browser does not support or is blocking cookies.
}

// Positive branch:
if (navigator.cookieEnabled) {
  console.log("Cookies look enabled");
}

⚡ Quick Reference

GoalCode
Read the flagnavigator.cookieEnabled
Cookies off?if (!navigator.cookieEnabled) { … }
Cookies on?if (navigator.cookieEnabled) { … }
Typetypeof navigator.cookieEnabled === "boolean"
Writable?No (read-only)
Status (MDN)Baseline Newly available

🔍 At a Glance

Four facts to remember about navigator.cookieEnabled.

Returns
boolean

true / false

Baseline
newly

Since Sept 2024

Access
read-only

No assignment

Best for
warnings

UX messaging

📋 cookieEnabled vs Test Cookie

navigator.cookieEnabledWrite / read document.cookie
SpeedInstant BooleanNeeds a small write + check
DetailBrowser-level enabled?Did this cookie stick?
Edge casesMay miss attribute-specific blocksCloser to real storage rules
Best forQuick UI warningCritical session / auth flows
Use together?Yes — check the flag first, then verify with a test cookie if needed

Examples Gallery

Examples follow MDN navigator.cookieEnabled patterns. Prefer Try It Yourself to inspect your browser. Use View Output for expected messaging.

📚 Getting Started

Read the Boolean and apply the MDN check.

Example 1 — Read cookieEnabled

Log the current Boolean value.

JavaScript
console.log(navigator.cookieEnabled);
Try It Yourself

How It Works

Most everyday browser setups return true. Disable cookies in settings to see false.

Example 2 — MDN if (!cookieEnabled) Check

Branch when cookies are unsupported or blocked.

JavaScript
if (!navigator.cookieEnabled) {
  console.log("Cookies unsupported or blocked");
} else {
  console.log("Cookies look enabled");
}
Try It Yourself

How It Works

This is MDN’s recommended shape: treat false as “do not rely on setting cookies.”

📈 Practical Patterns

User messaging, type checks, and a reusable helper.

Example 3 — Friendly UI Message

Build a short status string for a banner or settings tip.

JavaScript
const msg = navigator.cookieEnabled
  ? "Cookies are enabled — preferences can be saved."
  : "Cookies are blocked — some features may not work.";
console.log(msg);
Try It Yourself

How It Works

Show this near login, cart, or consent UI so users know why a feature might fail.

Example 4 — Confirm Boolean Type

Verify the property is a Boolean (beginner sanity check).

JavaScript
const lines = [
  "value: " + navigator.cookieEnabled,
  "typeof: " + typeof navigator.cookieEnabled
];
console.log(lines.join("\n"));
Try It Yourself

How It Works

You get a real Boolean — not the strings "true" / "false".

Example 5 — Status Helper + Optional Test Cookie

Combine the flag with a tiny write/read check for extra confidence.

JavaScript
function cookieStatus() {
  if (!navigator.cookieEnabled) {
    return { ok: false, reason: "cookieEnabled-false" };
  }
  const key = "ctf_cookie_test";
  document.cookie = key + "=1; path=/; max-age=60";
  const stored = document.cookie.split("; ").some((c) => c.indexOf(key + "=") === 0);
  // cleanup
  document.cookie = key + "=; path=/; max-age=0";
  return stored
    ? { ok: true, reason: "enabled-and-writable" }
    : { ok: false, reason: "write-failed" };
}

console.log(JSON.stringify(cookieStatus()));
Try It Yourself

How It Works

Use the flag first; the optional test cookie catches cases where the flag is true but storage still fails for your page.

🚀 Common Use Cases

  • Login / session warnings — tell users cookies are required before they submit.
  • Preference storage — fall back to localStorage or in-memory state when cookies are off.
  • Consent / cookie banners — adjust messaging when the browser already blocks cookies.
  • Checkout / cart — surface a clear error instead of a silent empty cart.
  • Diagnostics — include cookieEnabled in support debug panels.

🧠 How navigator.cookieEnabled Works

1

Read the property

Access navigator.cookieEnabled in your script.

Read
2

Browser reports status

Returns true or false for cookie enablement.

Boolean
3

Branch your UX

Warn, degrade gracefully, or proceed with cookie features.

UX
4

Optional deeper check

For critical paths, also verify a short-lived test cookie.

📝 Notes

  • Baseline Newly available (MDN, since September 2024).
  • Not Deprecated, Experimental, or Non-standard — no status banner required.
  • Read-only Boolean on Navigator.
  • true does not guarantee every cookie attribute (for example SameSite=None) will succeed.
  • Related: credentials, Window, JavaScript hub.

Universal Browser Support

navigator.cookieEnabled is Baseline Newly available across modern browsers (MDN: since September 2024). Use it as a quick cookies-enabled check and keep a clear message when it is false.

Baseline · Newly available

Navigator.cookieEnabled

Read the Boolean early for UX warnings. For critical session flows, optionally verify with a test cookie.

Universal Newly available
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
cookieEnabled Excellent

Bottom line: Check navigator.cookieEnabled, warn when false, and remember attribute-specific cookie rules can still apply.

Conclusion

navigator.cookieEnabled is a simple, Baseline Boolean for cookie enablement. Use the MDN if (!navigator.cookieEnabled) pattern to warn users, and optionally confirm with a short test cookie when sessions matter.

Continue with credentials, Window methods, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Check before cookie-dependent login / cart flows
  • Show a clear “enable cookies” message when false
  • Offer non-cookie fallbacks when possible
  • Remember attribute rules still apply when true
  • Use a test cookie for mission-critical storage

❌ Don’t

  • Assume true means every cookie option works
  • Fail silently when cookies are blocked
  • Try to assign to cookieEnabled
  • Confuse this with cookie consent preference APIs
  • Skip HTTPS/Secure rules for cross-site cookies

Key Takeaways

Knowledge Unlocked

Five things to remember about cookieEnabled

Baseline Boolean — cookies on or blocked.

5
Core concepts
02

true

Cookies enabled

OK
🚫 03

false

Blocked / unsupported

Warn
🔒 04

Access

read-only

API
🎯 05

Status

Baseline

Modern

❓ Frequently Asked Questions

It is a read-only Navigator property that returns a Boolean: true when cookies are enabled, false when the browser does not support cookies or is blocking them from being set.
No. MDN marks it as Baseline Newly available (since September 2024). It is a standard HTML Navigator property — not Deprecated, Experimental, or Non-standard.
Read navigator.cookieEnabled. MDN’s pattern: if (!navigator.cookieEnabled) { /* cookies unsupported or blocked */ }.
Not always. Browsers may still block certain cookies in some scenarios — for example SameSite=None cookies often need HTTPS and the Secure attribute. cookieEnabled is a high-level on/off check, not a guarantee for every cookie option.
No. The property is read-only. You read the Boolean; you do not assign to it.
For critical flows, you can also try a short-lived test cookie and verify it was stored. cookieEnabled is the quick first check; a write/read test confirms storage for your site’s rules.
Did you know?

MDN notes that even when cookies are generally enabled, browsers may still refuse certain cookies — for example SameSite=None without HTTPS and the Secure attribute.

Learn credentials Next

Credential Management API for smoother sign-in.

credentials →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful