HTML DOM Navigator cookieEnabled Property

Last Updated : 27 Oct, 2026

The navigator.cookieEnabled property is a read-only JavaScript boolean that returns true if the user's browser accepts cookies.

HTML
<!--Driver Code Starts-->

<!DOCTYPE html>
<html>
<head>
    <title>
      Navigator cookieEnabled Property in HTML
    </title>
    <style>
        h1 {
            color: green;
        }
        h2 {
            font-family: Impact;
        }
        
        body {
            text-align: center;
        }
    </style>
</head>
<body>
    <h1>GeeksforGeeks</h1>
    <h2>Navigator cookieEnabled Property</h2>
    <p>
      For checking whether cookies are enabled in the browser,
      double click the "Check Cookies" button:
    </p>
<!--Driver Code Ends-->

    <button ondblclick="checkcookies()">Check Cookies</button>
    <p id="check"></p>
    <script>
        function checkcookies() {
            var c = 
                "Are cookies enabled : " + navigator.cookieEnabled;
            document.getElementById("check").innerHTML = c;
        }
    </script>

<!--Driver Code Starts-->
</body>
</html>
                         
<!--Driver Code Ends-->

Syntax

navigator.cookieEnabled
  • It checks global settings, meaning it cannot detect if an ad-blocker or strict anti-tracking extension is blocking cookies on your specific site.
  • It only verifies first-party cookies; privacy-focused browsers might still return true even if they actively block all third-party cookies.
Comment