<html>
<! JustACookie.php                                            >
<! Chapter 12, Oracle Database XE PHP Web Programming         >
<! by Michael McLaughlin                                      >
<!                                                            >
<! This demonstrates how to set a cookie and then obsolete    >
<! the cookie.                                                >
<head>
<title>
  Chapter 12 : JustACookie.php
</title>
<style type="text/css">
  div#centered {border:0;height:50%;top:25%;left:25%;width:50%;
                position:absolute;}
</style>
</head>
<body>
<?php
  // Check if a cookie is set and read its contents.
  if (isset($_COOKIE['MyCookie']))
    print "MyCookie is set to: [".$_COOKIE['MyCookie']."]<br>";
  else
  {
    // Print the cookie is not set.
    print "MyCookie is not set.<br>";

    // Set the cookie for a two minute life span.
    setcookie("MyCookie", 'A simple string value', time() + 120, '/');

  }

  // Read all cookies available cookies sent in the URL.
  if (isset($_COOKIE))
    foreach ($_COOKIE as $name => $value)
      print "Cookie Name [$name]; cookie value [$value]<br>";
?>
</body>
</html>