Tracking unique visitors only?

Viewed 28513

Currently I have a file called "hits.php" and on any page I want to track page hits I just use <?php include("hits.php"); ?>

How can I track unique visitors only though? My hits are false since it can be refreshed by the same person and hits go up.

Here's my source:

<?php
 $hits = file_get_contents("./client/hits.txt"); 
 $hits = $hits + 1; 

 $handle = fopen("./client/hits.txt", "w"); 
 fwrite($handle, $hits); 
 fclose($handle); 

 print $hits; 

?>

I don't really know how I could do cookie checking... is there a way to check IP's? Or what can I do?

Thanks StackO.

7 Answers

You could save a timestamp to localStoage in javascript. LocalStoage isn't removed by the browser, so you should be save to check against that. I know that it isn't serverside checking, but it may be helpful anyway.

Related