title: What's the best way to count unique visitors on my webpage?
body: <p>I create a php class to count unique visitors on my webpage, my ideas is create a cookie that stays on the visitor computer until 23:59 of the current day, if the cookie exite it means that the site has already been visited and does not do anything, if it does not exist then create the cookie and account new visit </p>
  
  <p>this is the code I have for creating the code, if the cookie exite it return false, if not create the cookie and return true.</p>
  
  <p>**</p>
  
  <pre><code>function CriakCookieDia(){  
      if (!isset($_COOKIE[sha1('visita')])){  
          $tempoAteAoFimDoDia=strtotime('tomorrow') - time();
          setcookie(sha1('visita'), true,  time()+$tempoAteAoFimDoDia);
          return true;    
      }else{
          return false;
      }
   }
  </code></pre>
  
  <p>**</p>
  
  <p>but I'm not having the expected result, instead of unique visits, it's like I count the number of views on the site, it's like I'm not creating the cookie, what's wrong about my approach?</p>