Hit counter...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Pratik Sheth
Forum Newbie
Posts: 4
Joined: Wed Oct 14, 2009 5:56 am

Hit counter...

Post 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...
User avatar
Grizzzzzzzzzz
Forum Contributor
Posts: 125
Joined: Wed Sep 02, 2009 8:51 am

Re: Hit counter...

Post 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..
Post Reply