title: After submit page shows old value of $_COOKIE[] until next refresh
body: <p>I am having an issue where after first clicking Submit, and the page reloads, the page shows the old value for each cookie set until the page is refreshed or reloaded.</p>
  
  <p>Here is essentially how I have it set up.</p>
  
  <p>index.php</p>
  
  <pre><code>&lt;?php 
      if(isset($_POST['filter'])){
          foreach($_POST['filter'] as $key=&gt;$value){
              $xNums[] = $key;    
          }
          $vals = $_POST['filter'];
          updateFilter($vals, $xNums);
      }
  ?&gt;
  &lt;form action='index.php' method='post'&gt;
  &lt;input type='radio' name=filter['".$xNum."'] value='yes' /&gt;Show&lt;input type='radio' name=filter['".$SomeVariable."'] value='no' /&gt;Hide
  &lt;input type=submit value=" Submit " /&gt;
  &lt;?php
      echo displayStatus($xNum);
  ?&gt;
  </code></pre>
  
  <p>functions.php</p>
  
  <pre><code>function updateFilter($vals, $xNums){
      foreach($xNums as $xNum){
          $val = $vals[$xNum];
          setcookie($xNum, $val, time()+3600);
      }
      return;
  }
  
  function displayStatus($xNum){
      if($_COOKIE["'".$xNum."'"]=='no'){
          return "no";
      } else {
          return "yes";
      }
  }
  </code></pre>