title: PHP Trying To Figure out A way to Refresh Session on Browser Refresh
body: <p>Hello I do find my self in an assignment challenge at the moment basically I have been able to implement the challenge completly but one thing I should be able to change the $_SESSION superglobal on Browse Refresh I had look all type of possible alternatives but none seem to work, any help is kindly apprecciated this is my code what Im looking for is a way for the $_SESSION to be changed on browser refresh a per the working version it seems to be possible I don't know which other way to try I had tried session unset or destroy but it deletes the whole form :</p>
  
  <pre><code>&lt;?php
  session_start();
  
  if(!isset($_SESSION['secret'])) {
    $possible_chars = array_merge(range('A','Z'),range('0','9'));
    shuffle($possible_chars);
    $string = substr(implode($possible_chars),0,5);
    $_SESSION['secret'] = $string;
  }
  else {
  ?&gt;
    &lt;!DOCTYPE html&gt;
    &lt;html lang="en"&gt;
    &lt;head&gt;
      &lt;meta charset="utf-8" /&gt;
      &lt;title&gt;THIS FORM POST TO ITSELF TO BE SURE THE USER ENTERS THE RIGHT INFO&lt;/title&gt;
      &lt;IMG SRC="index.php" alt="captcha"/&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;h1&gt;Captcha Form&lt;/h1&gt; 
      &lt;form method="post" action="index.php"&gt;
        &lt;fieldset&gt;
          &lt;ul&gt;
            &lt;li&gt;
              &lt;label for="email"&gt;Email&lt;/label&gt;
              &lt;br&gt;
              &lt;input name="email" id="email" value="&lt;?php if(isset($_POST['email'])) echo $_POST['email']; ?&gt;" /&gt;
            &lt;/li&gt;
            &lt;li&gt;
              &lt;label for="comments"&gt;Comments&lt;/label&gt;
              &lt;br&gt;
              &lt;input name="comments" id="comments"  value = "&lt;?php if(isset($_POST['comments'])) echo $_POST['comments']; ?&gt;" /&gt;
            &lt;/li&gt;
            &lt;li&gt;
              &lt;label for="captcha"&gt;Please input CAPTCHA:&lt;/label&gt;
              &lt;br&gt;
              &lt;input name="captcha" id="captcha"/&gt;
            &lt;/li&gt;
            &lt;li&gt;
              &lt;input type="submit" name="submit" value="Submit My Captcha!"/&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
          &lt;?php print_r($_SESSION['secret']); ?&gt;
          &lt;br\&gt;
          &lt;br\&gt;
          &lt;?php
          $answer = (isset($_POST['captcha']) ? $_POST['captcha'] : null);
          $email = (isset($_POST['email']) ? $_POST['email']: null);
          $comments = (isset($_POST['comments']) ? $_POST['comments']: null);
          if( !empty( $_POST )) {
            if (strcasecmp($answer,$_SESSION['secret']) != 0) {
              //($_SESSION['secret'] != $answer )
              echo "Fee Fi Fo Fum Fot I smell the blood of an automated bot!";
              //$_SESSION['secret'] = NULL;
              header('captcha_challenge.php');
              //$_SESSION['secret'] = NULL;
            }
            elseif (strcasecmp($answer,$_SESSION['secret']) == 0) {
              //($_SESSION['secret'] == $answer)
              unset ($_SESSION['secret']);
              $_SESSION['email'] = $_POST['email'];
              $_SESSION['comments'] = $_POST['comments'];
              $query = ("INSERT INTO comments (email, content) VALUES ( '$email', '$comments')");
              $results = $db-&gt;query($query);
              header('Location:goodMessage.php');
            }
          }
  }
  ?&gt;
  </code></pre>