title: Does refreshing a page destroy PHP sessions?
body: <p>I've got a captcha command that sets the value of a Session and then refreshes the page if the captcha code isn't correct.</p>
  
  <p>In verification section of the page:</p>
  
  <pre><code>$_SESSION['refresh']=1;
  echo '&lt;META HTTP-EQUIV="Refresh" Content="0"; URL="contact-test.php"&gt;'; 
  </code></pre>
  
  <p>When the page loads it runs a bit of php script to see if there is a value set for a session variable, if there is it then echos a javascript function for an alert box, which called in the in the body via an onLoad command.</p>
  
  <p>At the very beginning of the code:</p>
  
  <pre><code>session_start();
  
  if (isset($_SESSION['refresh'])) {
      echo '&lt;script type="text/javascript"&gt;
         function loadalert ()
         {alert("Incorrect security code, please try again.")}
      &lt;/script&gt;';}
  </code></pre>
  
  <p>Near as I can tell when the page refreshes the sessions value is lost, I suspect the session_start() command is clearing all previous sessions.  I've tried a test echo sending out some text and the value of the session, both before the loop and in the loop;  only the one before the loop gets echoed without a session value at refresh.</p>