Skip to main content
June 14, 2010
Answered

No Cookie Redirect

  • June 14, 2010
  • 2 replies
  • 584 views

Hi Chaps,

Quick question on this one, I've got a <noscript> tag in my HTML to check to see if Javascipt in enabled, but how do you check to see if cookies are enabled?
Is there HTML code / PHP function, or do you simply try to set a cookie and redirect on failure to read the cookie you just to to set?

Cheers

This topic has been closed for replies.
Correct answer

Do it w/ php by setting a cookie at the beginning of the page then if/else where if cookie isset then show cookie page else show no cookie page.

http://www.w3schools.com/PHP/php_cookies.asp

2 replies

Correct answer
June 16, 2010

Do it w/ php by setting a cookie at the beginning of the page then if/else where if cookie isset then show cookie page else show no cookie page.

http://www.w3schools.com/PHP/php_cookies.asp

June 16, 2010

Can be done with JavaScript:

<script type="text/javascript">
document.cookie = "Test=cookie";

if(document.cookie.indexOf("Test") == -1){
     alert("Disabled");
} else {
     alert("enabled");
}
</script>