title: Cookie not setted or not working the first time
body: <p>On every page I set a cookie to color the header button corresponding to that session.
  The problem is that the first time I open a page in a different section, the cookie remains the old, and the colored button too.
  Then if I click another time the same button, the cookie is correctly setted. Why?</p>
  
  <p>Here my code:</p>
  
  <pre><code>&lt;?php
  include $_SERVER['PERCORSO_GLOBALS'];
  
  $pagelevel = '1';
  require_once ROOT_DIR.'/administrator/flock/session_users.php';
  
  setcookie('lng', 'it');
  ?&gt;
  
  &lt;head&gt;
      ...
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;?php
  $currentpage = basename(__FILE__);
  
  function colorButtonHeader($section){
      if(isset($_COOKIE['lng'])){
          if($_COOKIE['lng'] == $section){
              echo "buttonon";
          }
      }else{
          echo 'Error';
          die($refresh);
      }
  }
  ?&gt;
  
  &lt;div id="button"&gt; 
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&lt;?=$index_admin?&gt;&gt;&lt;span class="&lt;?php colorButtonHeader('home') ?&gt;"&gt;HOME&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&lt;?=$italiano?&gt;&gt;&lt;span class="&lt;?php colorButtonHeader('it') ?&gt;"&gt;ITALIANO&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&lt;?=$tedesco?&gt;&gt;&lt;span class="&lt;?php colorButtonHeader('de') ?&gt;"&gt;DEUTSCH&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&lt;?=$francese?&gt;&gt;&lt;span class="&lt;?php colorButtonHeader('fr') ?&gt;"&gt;FRANÇAIS&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt; 
  &lt;/div&gt; 
  
  
  ?&gt;
  
  &lt;div id="content"&gt;
  
       ...
  
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>