title: The corret session declaration
body: <p>I am just confused with the session in the login configuration. </p>
  
  <p>For example:</p>
  
  <pre><code>        if($ensure_credentials) {
          $_SESSION['status'] = 'authorized';
          $_SESSION['username'] = $username; /* save the users username to session */
          header("location: index.php");
      } else return "Please enter a correct username and password";
  </code></pre>
  
  <p>In there it is declared if the login success so that the session status is authorized. But why in the index page it is declared like this:</p>
  
  <pre><code>        session_start();
      if($_SESSION['status'] !='authorized') header("location: login.php");
  </code></pre>
  
  <p>Which it means that if the session status is authorized than it will be directed to login page. </p>
  
  <p>I have to ask this question because it always direct me back to login page. </p>