title: php sessions to authenticate user on login form
body: <p>I have the following code designed to begin a session and store username/password data, and if nothing is submitted, or no session data stored, redirect to a fail page.</p>
  
  <pre><code>session_start();
  if(isset($_POST['username']) || isset($_POST['password'])) {
      $username = $_POST['username'];
      $password = $_POST['password'];
      $_SESSION['username'] = $username;
      $_SESSION['password'] = $password;
  }
  
  if(isset($_SESSION['username']) || isset($_SESSION['password'])){
      $navbar = "1";
      $logindisplay = "0";
      $username = $_SESSION['username'];
      $password = $_SESSION['password'];
  } else {
      header('Location:http://website.com/fail.php');
  }
  
  $authed = auth($username, $password);
  if( $authed == "0" ){
      header('Location:http://website.com/fail.php');
  }
  </code></pre>
  
  <p>Its not working the way it should and is redirecting me to fail even though i submitted my info and stored it in the session. Am i doing something wrong? </p>
  
  <p><strong>NOTE</strong> the authed function worked fine before i added the session code.</p>