<html>
<! SessionFileWrite.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 : SessionFileWrite.php
</title>
</head>
<body>
<?php
  // Start a session and assign session identifier to variable.
  if (session_start())
    $session_id = session_id();

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

  // Read existence of the session or return not set message.
  if (isset($session_id))
  {
    // Write to the server-side session through the predefined variable.
    $_SESSION['username'] = "username";
    $_SESSION['password'] = "password";
  }

  // Read contents of server-side session file.
  foreach ($_SESSION as $name => $value)
    print "[$name][$value]<br />";
?>
</body>
</html>