Code2care : TechZone Apps & Tutorials

Detect if Cookies are enabled using javascript

If you are implementing cookies for your web project you need to know first that are cookies enabled or disabled by the user web browser. This can be done with the help of cookieEnabled available in window.navigator object.

On the load of the webpage we can call a javascript function that checks if cookies are enabled or not.

<!DOCTYPE html>
<title>Check if cookies are enabled or disabled</title>

<script type="text/javascript">

function checkCookiesStats() {

 if(navigator.cookieEnabled) {

   document.getElementById("check").innerHTML =
    "Cookies are enabled!!";

  else {

   document.getElementById("check").innerHTML =
    "Cookies are disabled!!";




<body onload="checkCookiesStats()">

<h2>Check Cookies stats</h2>

<p id="check"></p>


Note : We do not need to prefix window to navigator.cookieEnabled.

navigator.cookieEnabled returns boolean true if cookies are enabled else false.


Posts related to javascript.

1. Top 15 Programming Languages to learn 2014-2015

2. How to detect Browser and Operating System Name and Version using javaScript

3. How to make jsfiddle bootstrap ready

4. Detect if Cookies are enabled using javascript

5. How to get UTC (GMT) using javascript

6. Add Animated Scrolling to Html Page Title Script

7. Loading previous page using html button using javascript

8. Get Device Screen Width and Height using javaScript

9. Digital clock example using javaScript with Source code


Popular tags
x 175
x 29
x 20
x 14
x 14
x 14
x 13
x 11

1000+ C Programs     PHP Tutorial     JSON Tutorial     Swift Tutorial     India Pinocdes     About Us     Privacy Policy

Code2care © 2012-17