Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 844947 of Navigator.cookieEnabled

  • Revision slug: Web/API/Navigator/cookieEnabled
  • Revision title: Navigator.cookieEnabled
  • Revision id: 844947
  • Created:
  • Creator: Sebastianz
  • Is current revision? Yes
  • Comment Added table to 'Specifications' section and fixed formatting of 'Browser compatibility' section

Revision Content

{{ ApiRef("HTML DOM") }}

Returns a Boolean value indicating whether cookies are enabled or not (read-only).

Syntax

var cookieEnabled = navigator.cookieEnabled;
  • cookieEnabled is a Boolean true or false.

Example

if (!navigator.cookieEnabled) { 
  // let the user know that enabling cookies makes the web page much more useful
}

Specifications

Specification Status Comment
{{SpecName("HTML WHATWG", "webappapis.html#dom-navigator-cookieenabled", "Navigator.cookieEnabled")}} {{Spec2("HTML WHATWG")}} Initial definition

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{ CompatVersionUnknown() }} {{ CompatGeckoDesktop(1.0) }} {{ CompatVersionUnknown() }}[1] {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }}
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }} {{ CompatGeckoMobile(1.0) }}[1] {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}

[1] Prior to Gecko 8.0 {{ geckoRelease("8.0") }}, window.navigator.cookieEnabled would report the wrong result if a site exception was in place for the page on which the check was performed. This has been fixed.

Revision Source

<p>{{ ApiRef("HTML DOM") }}</p>

<p>Returns a Boolean value indicating whether cookies are enabled or not (read-only).</p>

<h2 id="Syntax" name="Syntax">Syntax</h2>

<pre class="eval">
var cookieEnabled = navigator.cookieEnabled;
</pre>

<ul>
 <li><code>cookieEnabled</code> is a Boolean <code>true</code> or <code>false</code>.</li>
</ul>

<h2 id="Example" name="Example">Example</h2>

<pre class="brush: js">
if (!navigator.cookieEnabled) { 
  // let the user know that enabling cookies makes the web page much more useful
}
</pre>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName("HTML WHATWG", "webappapis.html#dom-navigator-cookieenabled", "Navigator.cookieEnabled")}}</td>
   <td>{{Spec2("HTML WHATWG")}}</td>
   <td>Initial definition</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p>{{ CompatibilityTable() }}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{ CompatVersionUnknown() }}</td>
   <td>{{ CompatGeckoDesktop(1.0) }}</td>
   <td>{{ CompatVersionUnknown() }}<sup>[1]</sup></td>
   <td>{{ CompatVersionUnknown() }}</td>
   <td>{{ CompatVersionUnknown() }}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatGeckoMobile(1.0) }}<sup>[1]</sup></td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatUnknown() }}</td>
  </tr>
 </tbody>
</table>
</div>

<p>[1] Prior to Gecko 8.0 {{ geckoRelease("8.0") }}, <code>window.navigator.cookieEnabled</code> would report the wrong result if a site exception was in place for the page on which the check was performed. This has been fixed.</p>
Revert to this revision