title: PHP Session Variables not saving after redirect?
body: <p>I seem to be having a strange problem all the sudden and I was hoping someone may have a suggestion...</p>
  
  <p>I have a login script that is supposed to register a session variable containing an error message if the login fails and then redirect the user to the page they came from. For example the user may have used the forum on index.php and the login fails and they are returned to index.php where a script displays the error message contained in the session variable. </p>
  
  <p>However, the session variables do not appear to be saving. For the record, I am using session_start() in the login script as well as any page that has a login form that should display the error message if the user is returned to that page because the login failed. </p>
  
  <p>My script is as follows:</p>
  
  <pre><code>if (isset($_POST['prev'])) {
    $prev = $_POST['prev'];
  }
  else {
    $prev = "login.php";
  }
  $_SESSION['Login_Error'] = $error;
  header("Location: $prev");
  </code></pre>
  
  <p>Then the script on the form pages is:</p>
  
  <pre><code>if (isset($_SESSION['Login_Error'])) {
    echo $_SESSION['Login_Error'];
  }
  </code></pre>
  
  <p>And the error I am getting is:</p>
  
  <pre><code>Notice: Undefined index: Login_Error in F:\EasyPHP-12.0\www\index.php on line 3
  </code></pre>
  
  <p>Any ideas as to why it isn't saving? If the login is successful the script sets a user id session variable which is working fine. Thanks for any suggestions.</p>