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

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

ยท

1 min read

Originally Published 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
  • 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 ๐Ÿ˜ƒ.