effective counter for unique number of visits in PHP & MySQL

Posted by Adnan on Stack Overflow See other posts from Stack Overflow or by Adnan
Published on 2010-04-24T08:36:44Z Indexed on 2010/04/24 8:43 UTC
Read the original article Hit count: 171

Filed under:
|
|
|
|

Hello,

I am creating a counter for unique number of visits on a post, so what I have until now is a table for storing data like this;

cvp_post_id  | cvp_ip | cvp_user_id

In cases a registered user visits a post, for the first time a record is inserted with cpv_post_id and cvp_user_id, so for his next visit I query the table and if the record is available I do not count him as a new visitor.

In cases of an anonymous user the same happens but now the cvp_ip and cpv_post_id are used.

My concerns is that I do a query every time anyone visits a post for checking if there has been a visit, what would be a more effective way for doing this?

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql