PHP - simple cookie checking script

<?php

if(isset($_GET['set']) && $_GET['set'] != 'yes')
{
  // Set cookie
  setcookie('test', 'test', time() + 60);

  // Reload page
  header("Location: cookie.php?set=yes");
  exit ;
}
else
{
  // Check if cookie exists
  if(isset($_GET['set']) && ! empty($_COOKIE['test']))
  {
    echo "Cookies are enabled on your browser";
  }
  else
  {
    echo "Cookies are <b>NOT</b> enabled on your browser";
  }
}
?>

October 21, 2011 at 3:53am / Code, PHP 

Comments On This Entry

Great stuff, you helepd me out so much!

Dilly @ 08:47:12 PM, Sunday, October 23, 2011

Compose New Blog Comment
    required = required field         warning HTML and URL's are not allowed

[back to main]