简体   繁体   English

php独特命中数

[英]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? 我正在考虑一个cookie,但一旦该网站有很多文章/配置文件,cookie会变大吗?

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. Cookies将完成这项工作,除非您有1000页,并且用户全部访问它们,否则如果您存储页面ID和访问时间戳,cookie的大小将保持在可接受的限制范围内。 Another alternative would be to store unique ip addresses in a DB and do some DB level work. 另一种方法是在数据库中存储唯一的IP地址,并进行一些数据库级别的工作。

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). 如果是后者,我强烈建议您不要重新发明轮子并获得Google Analytics帐户(免费)。 This will give you considerably more useful information that a simple hit counter. 这将为您提供更简单的点击计数器的更多有用信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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