I have a jQuery-based web app. My requirement is fairly simple: I want to use jQuery to find out if the user has enabled or disabled cookies in their web browser. I\'m aware
Why are you testing with the property cookieEnabled
? just try to create a cookie and check if it's done. And in case cookies work, delete the test created cookie.
function are_cookies_enabled()
{
document.cookie="testcookie=valid";
cookieEnabled = (document.cookie.indexOf("testcookie") != -1) ? true : false;
if(cookieEnabled){
document.cookie = "testcookie=; expires=Thu, 01 Jan 1970 00:00:00 UTC;";
}
return cookieEnabled;
}