计算不重复访客 [英] Counting Unique Visitor

查看:137
本文介绍了计算不重复访客的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  • 我想计算唯一身份访问者并将其显示给访问者。

  • 我不想使用任何第三方工具(例如分析工具或其他
    东西)

什么是唯一身份访问者? REAL唯一身份访问者是否会随着IP,cookie或MAC发生变化?

What is a unique visitor exactly? Does the REAL unique visitor changes with IP, cookie or MAC?

我一直这样:


  • 获取访问者IP地址

  • 从数据库中搜索它

  • 如果存在,请勿执行任何操作

  • 如果不存在,请插入IP地址并服务器到数据库的时间并将其添加到计数中

  • Get visitors IP adress
  • Search it from database
  • If exists, don't do anything
  • If not, insert IP adress and server time to database and add this to count

这种方法对吗?我应该使用Cookie还是获得MAC地址?顺便说一句,所有这些事情-获取信息,存储信息,比较信息-合法吗?

Is this way right? Should I use cookies or get MAC adresses too? BTW all these things -getting information, store it, compare it- legal?

还有最后一个问题。我可以在没有数据库的情况下做所有这些事情吗?仅使用JS,PHP和文本文件或其他方式?

And one last question. Can I do all these things WITHOUT database? Only with using JS, PHP and text files or something else?

推荐答案

IP和MAC并不是好主意,因为:

IP and MAC are not good ideas, because:


  1. 许多用户可以共享相同的IP地址,例如

  2. 除非有特殊软件(不是普通的HTTP服务器)并且在LAN上运行,否则您将无法访问客户端的MAC地址。或者您利用浏览器中的一些安全漏洞,但不算在内;)

设置一个具有唯一生成值的cookie很好想法,但请注意,客户端可以关闭和删除Cookie。就合法性而言,只要您声明使用cookie且不做邪恶的事情(可以计算唯一身份的访问者就可以),那么您就很安全。

Setting a cookie with a uniquely generated value is a good idea, but be aware that cookies can be turned off and erased by the client. As of legality, as long as you declare the usage of cookies and you don't do evil things (counting unique visitors is ok), you are safe.

如果假设没有cookie的客户端是新来访者,那么您既不需要数据库也不需要cookie中的唯一值,只需检查cookie是否存在并进行设置即可。如果您想获取更多信息,那么,是的,您必须跟踪cookie中的唯一值。

If you assume that a client with no cookie is a new visitor, then you don't need neither a database nor a unique value in the cookie, simply check if the cookie is present or not and set it. If you want to get more information, then, yes, you will have to keep track of unique values in cookies.

这篇关于计算不重复访客的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆