Forum Moderators: open

Message Too Old, No Replies

Check for enabled browser Cookies

         

IT_Master

4:07 pm on Feb 10, 2004 (gmt 0)

10+ Year Member



hello all

Could you please tell me if it is possible to have a javascript which checks a web browser if it has cookies enabled and if not to display a message to the user that he/she has to enable cookies. thank you in advance

BlobFisk

4:54 pm on Feb 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could use the navigator.cookieEnabled property?


var supportsCookies =(navigator.cookieEnabled)? true : false;

if(supportsCookies) {
...
}

For older browsers you could try setting a cookie and then testing for the presence of that cookie.

HTH

IT_Master

5:18 pm on Feb 10, 2004 (gmt 0)

10+ Year Member



What about:

<SCRIPT LANGUAGE="javascript">
cookiestring = "test=1;EXPIRES=Sunday, 03-Apr-11 23:59:59 GMT;"
document.cookie = cookiestring;
if (document.cookie) { cookiestring = "test=1;EXPIRES=Wednesday, 04-Apr-01 03:09:32 GMT;"
document.cookie = cookiestring; }
else { document.location = "http://simpsongroup.co.uk/simpsongroup/checkifcookiesareenabled.htm"; }
</SCRIPT>