简体   繁体   中英

php unique hit count

i have a hit count on various parts of my site (profiles, news items, etc). At the moment it will increase the count if you refresh the page even though it's been visited. How can I stop going up if its visited? I was considering a cookie but once the site has a lot of articles/profiles the cookie will get big?

Cookies will do the job and unless you have 1000's pages and a users visits them all then the size of the cookie will remain well within acceptable limits if you store a page id and a visit timestamp. Another alternative would be to store unique ip addresses in a DB and do some DB level work.

That said...

Are your tracking for the purposes of displaying the hit count to users? Or any you tracking for your own administrative/curiosity reasons?

If the latter I would strongly suggest that you don't reinvent the wheel and get a Google Analytics account (free). This will give you considerably more useful information that a simple hit counter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM