COOKIES
COOKIES
The loggedin.php script prints a greeting to a user based upon a stored cookie.
The login.php script now uses every argument the setcookie() function can take
The header.html file now displays either a login or a logout link depending upon the
user’s current status.
19 <li><?php
20 // Create a login/logout link.
21 if ( (isset($_SESSION['user_id'])) && (!
strpos($_SERVER['PHP_SELF'], 'logout.php')) ) {
22 echo '<a href="logout.php" title="Logout">Logout</a>';
23 } else {
24 echo '<a href="login.php" title="Login">Login</a>';
25 }
26 ?></li>
4 session_name ('YourVisitID');
5 session_start(); // Start the session.
This version of the login.php script does not use cookies at all, instead maintaining the
state by passing the session ID in the URL
This final version of the login.php script also stores an encrypted form of the user’s
HTTP_USER_AGENT (the browser and the operating system of the client) in a session.
This loggedin.php script now confirms that the user accessing this page has the same
HTTP_USER_AGENT as they did when they logged in.