A PHP code which checks for a cookie?

  • Thread starter Thread starter leito339
  • Start date Start date
L

leito339

Guest
could some one link me to a PHP code which checks for a cookie and if it doesn't find it it redirects to another page, but if it does find it nothing happens?

Thanks
Leito
 
<?php
if(isset($_COOKIE["Name"]))
{
header("location: somewhere.php");
}

?>

don't forget that all of this comes before the header, so it has to be the first thing sent or it doesn't work. The other alternative would be to buffer your headers, but it's probably just easier to make sure this is stated first.
 
<?php
if(isset($_COOKIE["Name"]))
{
header("location: somewhere.php");
}

?>

don't forget that all of this comes before the header, so it has to be the first thing sent or it doesn't work. The other alternative would be to buffer your headers, but it's probably just easier to make sure this is stated first.
 
Back
Top