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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.