title: Problem unsetting a session variable
body: <p>There's a form on my site that's used for inviting friends. It's a simple text field and a submit button. If there is an error I redirect back to this page and display an error message if their is a session variable set.</p>
  
  <pre><code>if (isset($_SESSION['invite_error'])) {
     echo $_SESSION['invite_error'];
     unset($_SESSION['invite_error']);
  }
  </code></pre>
  
  <p>However, if I navigate away from this page and come back to it -the error message is still being displayed. If I navigate away and come back one more time it will be done. It's the same when I refresh that page...1 refresh won't get rid of it, but 2 will. I can't destroy the entire session, I just want to unset this one variable. PHP version is 5.2.5 build 6, register globals is off, I'm calling session_start() at the top of this page, I've tried using a no-cache header as well.</p>
  
  <p>Edit: Added full code.</p>
  
  <pre><code>&lt;?php 
  ob_start();
  session_start();
  
  $user_id = $_SESSION['user_id'];
  $user_name = $_SESSION['user_name'];
  
  if ($user_id==null) header("Location: /login.php");
  
  if (isset($_SESSION['invite_errors'])) {
  
      $error = $_SESSION['invite_errors'];
      unset($_SESSION['invite_errors']);
  
  }
  
  require_once("ui/header.php");
  ?&gt;
  
  
  
  &lt;div id="invite" class="content"&gt;
  
      &lt;?php if($error) { ?&gt;
          &lt;div class="errors round"&gt;
              &lt;?php echo $error ?&gt;
          &lt;/div&gt;
      &lt;?php } ?&gt;
  
      &lt;h3&gt;Invite Your Friends&lt;/h3&gt;
  
      &lt;div class="invite-form"&gt;
          &lt;form method="post" action="controllers/invite.php"&gt;
              &lt;div class="row"&gt;
                  &lt;textarea class="txt-area" name="emails" id="emails" rows="5"&gt;&lt;/textarea&gt;
                  &lt;div class="tip"&gt;Separate multiple email addresses with ,&lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="row-submit"&gt;
                  &lt;input type="submit" name="submit" id="submit" class="submit-btn" value="Submit" /&gt;
              &lt;/div&gt;
          &lt;/form&gt;
      &lt;/div&gt;
  
  &lt;/div&gt;
  
  &lt;?php
      require_once("ui/footer.php");
  ?&gt;
  </code></pre>