Page 1 of 1

Hit counter...

Posted: Tue Oct 20, 2009 6:14 am
by Pratik Sheth
hi
can any1 help me with a prob of hit counter m strucked in between..

i need to write a php code for hit counter with the help of cookie...
where the counter should show only one visit per day from one IP

please help me out.
thanks...

Re: Hit counter...

Posted: Tue Oct 20, 2009 7:06 am
by Grizzzzzzzzzz

Code: Select all

 
 
<?php
if (isset($_COOKIE["example"]))
{
      //if cookie already exists, do nothing
}
else
{
     setcookie("example", "whatever", time()+86400);
     //create a cookie lasting for a day
 
     $hitcounter++;
     //increment the hitcounter by 1
}
?>
 
 
although, the hitcounter could still be incremented by the same person; using a different browser, deleting cookies etc..