Jump to content

Redirect using cookie


JayVee

Recommended Posts

if(document.cookie.length > 0 && document.cookie.substr(0, document.cookie.indexOf("=")) == cname) {
   if(document.cookie.substr(document.cookie.indexOf("=") + 1) == "no") {
      location.href = "index.php";
   } else {
      // cookie data was something other than no
   }
} else {
   location.href = "index.php"; // cookie wasn't set
}

 

I *think* that would do assuming the cookie format is just cname=no.  Things to lookout for are indexOf is case sensitive, and it returns -1 if the match string isn't found.

 

HTH

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.