如何确定网站用户是否是唯一的或 ASP.NET 中的回访用户?
单个用户在访问某个网站时可以在一段时间内显示为多个唯一用户。 在内部,用户的IP地址是静态的,但在网络上,用户是由ISP路由器的IP地址代表的,不是吗?
A single user can show up as multiple unique users over a period of time when he vists a site. Internally, the user's IP address is static, but on the net the user is represented by the ISP router's IP address, isn't it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您无法通过 IP 地址保证用户是唯一的。
公司可能在防火墙/代理后面运行,因此所有请求都将来自该单一 IP。
也许您最好的选择是在用户浏览该网站时在用户浏览器上放置一个 cookie,然后在后续访问时检查该 cookie 是否存在。
但即使这样也不能保证您的安全,因为没有什么可以阻止用户清除浏览器中的 cookie,或者从 IE 访问一次,然后从 Firefox 访问。
简而言之,没有保证的方法......但有一些方法可以做出很好的猜测
You can't be guaranteed that a user is unique by IP Address.
Companies might be operating behind a firewall/proxy so all requests will come from that single IP.
Probably your best bet would be to drop a cookie on to the users browser when they browse to the site, and then check for the existence of that cookie on subsequent visits.
But even this doesn't guarantee you as there is nothing to stop the user from clearing their cookies in the browser, or visiting once from IE, and the next time from firefox.
In a nutshell, there's no guaranteed way... but there are ways to make a pretty good guess
对于访问您网站的每个客户,为他分配一个唯一的 ID 并将其存储在 cookie 中。 然后在每次访问您的网站时检查该 cookie,如果丢失则进行设置。 然后您可以通过唯一 ID 记录客户端使用情况。
通常你从客户端看到的IP地址是客户端的ISP为他提供的IP地址。 这些通常是动态的。 代理和路由器后面的客户端将共享 IP 地址。 不管怎样,为每个客户端分配一个唯一的 cookie 可以避免这些问题。
它不适用于禁用 cookie 的客户端。 您必须默认使用这些 IP 地址,并冒着数据不正确的风险。 或者您可以不登录此类用户,这样您的数据将不完整。 没有可靠的方法来唯一区分每个用户,因此您只需选择对您的网站最有意义的方法即可。
For every client that comes to your site, assign him a unique ID and store it in a cookie. Then check for that cookie every time your site is hit, and set it if it is missing. Then you can log client usage by unique ID.
Usually the IP address you see from the client is the IP address the client's ISP has provided for him. These are often dynamic. Clients behind proxies and routers will share IP addresses. Either way, assigning a unique cookie to each client circumvents these problems.
It won't work for clients with cookies disabled. You'll have to default to the IP address for those, and risk the data being incorrect. Or you could just not log this kind of user, in which care your data will be incomplete. There's no reliable way to uniquely distinguish between every user, so you just have to pick which method makes the most sense for your site.