Jump to content

Recommended Posts

session id's wouldn't really work.  Random Joe goes to your site and views the page, and you start a session, it only prevents the counter from incrementing as long as he's at your site, or even has the browser open.  But as soon as he closes it, the session expires.  Joe comes back to your site, gets assigned a new session id, and bam, he's another unique visitor.

The only [i]more[/i] accurate way is if the only way a user can view the page is if the user is logged in.  Then you can keep track of whether each user has viewed the topic or not.  But really, that's a whole lot of useless data buildup.  If you have 1,000 users and 1,000 topics that's up to 1,000,000 rows in a table to keep track of whether the view was unique or not.  And 1,000 users and 1,000 topics is a drop in a bucket.  And again, that's assuming you only want to make the topics only viewable by logged in members.

Keeping a list of IP addresses to find out unique views does leave a margin of error, as peoples' IP address change all the time, but it's an acceptable tradeoff.  What you can also do to narrow that margin is to set a cookie and have your script check for it.  Some people don't allow cookies, so again, it's not a 100% thing, but a lot of people do allow cookies, so it should help narrow the margin.

You could also force cookies on the user.  That is, have your script try to make a cookie and if it fails, give a message to the user that they can't view your site without enabling cookies.  Then, you can have your counter only increment if it doesn't find a cookie initially.  This may or may not be a desirable thing, though.

Just keep in mind that simply keeping a list of ip addresses and checking for a cookie (but not forcing it) does leave an acceptable margin of error for most professional sites.  It really depends on the nature of your site, what type of people your expected visitors are, and how your site is setup in the first place, etc.. as to what really is the most efficient way to go about this is. 
thanks a lot mate you helped me out a great deal i will give the cookies a go if not i'll just get it to increment every time a user just clicks on the page .. it ain't a unique visit but i guess it has to do.

thanks again this has been puzzling me for some time :)
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.