<html>
<! SessionCookie.php                                          >
<! Chapter 12, Oracle Database XE PHP Web Programming         >
<! by Michael McLaughlin                                      >
<!                                                            >
<! This demonstrates that session_start() automatically       >
<! writes a cookie to the server. You can find it in the      >
<! C:\WINDOWS\temp directory on windows.                      >
<!                                                            >
<! The session.name directive sets the default cookie name of >
<! PHPSESSID, which is used below in the program.             >
<head>
<title>
  Chapter 12 : SessionCookie.php
</title>
</head>
<body>
<?php
  // Start a session and assign session identifier to variable.
  if (session_start())
    $session_id = session_id();

  // Print description.
  print "Initial Server-side State:<br />";

  // Read existence of the session or return not set message.
  if (isset($session_id))
    print "Session Data: ['Server-side File'][".$session_id."]<br>";
  else
    print "Session Data: ['Server-side File'][Not Currently Set]<br>";

  // Print description.
  print "<hr />";
  print "Initial Client-side Cookie State:<br />";

  // Read session cookie or return not set message.
  if (isset($_COOKIE['PHPSESSID']))
    print "Session Cookie: ['PHPSESSID'][".$_COOKIE['PHPSESSID']."]<br>";
  else
    print "Session Cookie: ['PHPSESSID'][Not Currently Set]<br>";
?>
</body>
</html>