title: Cookie not set until a second refresh
body: <p>I have a form on page 1:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;form method=&quot;post&quot; action=&quot;request-form&quot;&gt;
      &lt;input
          type=&quot;text&quot;
          id=&quot;amzQry&quot;
          name=&quot;item&quot;
          placeholder=&quot;What do you need?&quot;
          autocomplete=&quot;on&quot;
      /&gt;
      &lt;input
          id=&quot;autocomplete&quot;
          name=&quot;destination&quot;
          placeholder=&quot;where? (e.g. Buenos Aires)&quot;
          onfocus=&quot;geolocate()&quot;
          type=&quot;text&quot;
          required=&quot;&quot;
          aria-required=&quot;true&quot;
          autocomplete=&quot;off&quot;
      /&gt;
      &lt;button type=&quot;submit&quot; value=&quot;&quot;&gt;
          Submit
      &lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  <p>I want this information to be held in a persistent way so that even if a user subsequently logs in (to joomla in this case) the cookie data is persistent and can be called. That is why i have used cookies rather than sessions in this case. Correct me if this is not the right way of doing this.</p>
  <p>I have some code to set and retrieve the cookie on page 2:</p>
  <pre class="lang-php prettyprint-override"><code>&lt;?php
      $itemcookie = $_POST['item'];
      $detsinationcookie = $_POST['destination'];
  
      setcookie(&quot;itemcookie&quot;, $itemcookie, strtotime('+30 days'));
      setcookie(&quot;destinationcookie&quot;, $detsinationcookie, strtotime('+30 days'));
  ?&gt;
  </code></pre>
  <p>But the cookie data is not appearing on the second page when it loads after form submit. If I refresh the second page the data appears in the right places, i.e. where I have called it with e.g.</p>
  <pre class="lang-php prettyprint-override"><code>&lt;?php
      echo $_COOKIE[&quot;itemcookie&quot;];
  ?&gt;
  </code></pre>
  <p>How to get the cookie data available immediately on page 2?</p>