title: Cookie page counter in php
body: <p>I am implementing a php page counter that will keep track of each time the user visits this page until the browser is closed. I am checking to see if the cookie is set, if it is. Then I am increment it and reset its value. But the problem I am having is that the counter is always at two, why is this?</p>
  
  <pre><code>&lt;html&gt; 
      &lt;head&gt; 
          &lt;title&gt;Count Page Access&lt;/title&gt; 
     &lt;/head&gt; 
    &lt;body&gt; 
  &lt;?php 
  
      if (!isset($_COOKIE['count']))
      {
          ?&gt; 
  Welcome! This is the first time you have viewed this page. 
  &lt;?php 
          $cookie = 1;
          setcookie("count", $cookie);
      }
      else
      {
          $cookie = $_COOKIE['count']++;
          setcookie("count", $cookie);
          ?&gt; 
  You have viewed this page &lt;?= $_COOKIE['count'] ?&gt; times. 
  &lt;?php  }// end else  ?&gt; 
     &lt;/body&gt; 
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>Edit: Thanks everyone, I did the pre increment thing and got it to work</strong></p>