title: Clear session variable after use
body: <p>Is it possible to use a session variable, then unset it directly after?</p>
  
  <p>Example:</p>
  
  <pre><code>//====
  //Process Form
  if ($_POST['Submit']) {
      $update = $userSettings-&gt;update($_POST);
  
      //If there are form errors
   if (!$update) {
          //Load the errors into an array
          $errors = $update[1];
      } else {
          //Set the session
          $_SESSION['showUpdated'] = true;
  
          //Redirect to this page
          header("Location: http://www.mysite.com/settings");
      }
  }
  
  //==================
  
  if ($_SESSION['showUpdated']) {
   echo "Settings Updated";
      unset($_SESSION['showUpdated'];
  }
  </code></pre>
  
  <p>So after the form is submitted, if there are no errors:</p>
  
  <ul>
  <li>Set a session to say the form submission was okay</li>
  <li>Reload the page (to prevent re-submitted POST data)</li>
  <li>If the 'showUpdated' session variable is set, display the "Updated" message</li>
  <li>Unset the session variable (so we don't see the message on next reload)</li>
  </ul>
  
  <p>Currently the problem is, if you unset the session variable straight after; It is as if you have un-set it before the "if exists" part.</p>
  
  <p>Any solutions? Is this even the best way to do it?</p>
  
  <p>Many thanks!</p>