Jump to content

how to calculate page view in php


beboo002

Recommended Posts

the problem with the above examples is that if someone was to go through your site and go to your home page numirous times, it would count them as a hit.

 

what i do is something like this:

 

if (!isset($_COOKIE['home'])) // check to see if they have been on the homepage before and if they have not the do below.
{
    setcookie("home","1",time()+3600); //set a cookie so that you know they have been to your home page within the last hour.
    mysql_query("update table set visitors=visitors+1"); //update the database.
}

 

that way you dont get loads of hits on that page if someone keeps going throught the site and hitting the same page all over again.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.