Simplest way to check if cookies are enabled or disabled - JavaScript

How can I make a simple check if cookies are enabled or disabled, using JavaScript ?
0
give a positive ratinggive a negative rating
Hi,

To make a simple check if cookies are enabled or disabled in visitor's web browser, you can use the following solution:

function checkCookies(){

document.cookie='c=1';
var v = document.cookie.indexOf("c=")!=-1;
document.cookie = 'c=1; expires=Thu, 01-Jan-1970 00:00:01 GMT';
if(v===true){ alert('Cookies are enabled'); }
else{ alert('Cookies are disabled'); }
}

Share on FacebookShare on TwitterShare on LinkedInSend email
1 answer
x
x
2024 AnswerTabsTermsContact us