JavaScript Test if cookies are enabled


If you want to make sure cookies are enabled before using them, you can use navigator.cookieEnabled:

if (navigator.cookieEnabled === false)
    alert("Error: cookies not enabled!");

Note that on older browsers navigator.cookieEnabled may not exist and be undefined. In those cases you won't detect that cookies are not enabled.