Source Code for /public/06-retaining-state/members.php

<?php
// Start the session:
session_start();

// Check if the user is logged in:
if( ! $_SESSION['logged_in'] ) {
  // They're not logged in - send them a HTTP 403 error code
  // ("forbidden") and information about logging in:
  header( 'HTTP/1.1 403 Forbidden' );
  ?>
  <h1>Forbidden</h1>
  <p>
    You're not logged in, so you can't access this page.
    <a href="login.php">Log in</a> to continue.
  </p>
  <?php
  die();
}
?>

<h1>Members area</h1>
<p>
  Welcome to the members area!
</p>
<p>
  If this was a real members area, there'd be all kinds of secret things here!
</p>
<ul>
  <li>
    <a href="login.php?logout=true">Log out</a>
  </li>
</ul>