DEV Community

Cover image for How to check if the cookie is enabled in a browser using JavaScript?
MELVIN GEORGE
MELVIN GEORGE

Posted on • Originally published at melvingeorge.me

10

How to check if the cookie is enabled in a browser using JavaScript?

Originally posted here!

To check whether a setting a cookie is enabled in the browser, you can use the cookieEnabled property in the window.navigator global object in JavaScript.

// check if cookie enabled in browser
const isCookieEnabled = navigator.cookieEnabled;

console.log(isCookieEnabled); // true
Enter fullscreen mode Exit fullscreen mode
  • The property will return a Boolean true if cookie enabled and return false if not enabled.

See this example live in JSBin.

Feel free to share if you found this useful 😃.


SurveyJS custom survey software

JavaScript UI Libraries for Surveys and Forms

SurveyJS lets you build a JSON-based form management system that integrates with any backend, giving you full control over your data and no user limits. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more.

Learn more

Top comments (0)

Neon image

Next.js applications: Set up a Neon project in seconds

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Get started →

👋 Kindness is contagious

DEV is better (more customized, reading settings like dark mode etc) when you're signed in!

Okay