Thursday, 31 July 2014

Checking if Cookies are Enabled in Browser

The simplest way to check for cookies is via JavaScript. The following function will return a boolean value -> true if cookies are enabled:, otherwise will return false.
<script >
function are_cookies_enabled()
 var cookieEnabled = (navigator.cookieEnabled) ? true : false;

 if (typeof navigator.cookieEnabled == "undefined" && !cookieEnabled)
  cookieEnabled = (document.cookie.indexOf("testcookie") != -1) ? true : false;
 return (cookieEnabled);

 var result= are_cookies_enabled();

A snippet of code using the function above was executed when you loaded this page. resutl will display true or false