在PHP中获取唯一的Web浏览器ID [英] Get Unique web browser ID in PHP

查看:498
本文介绍了在PHP中获取唯一的Web浏览器ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种将Web浏览器的唯一ID存储在PHP中的方法吗?我到处搜索..但是找不到任何有用的东西.首先,网络浏览器是否具有唯一的ID或类似的名称来标识它们???就像计算机有一个唯一的IP地址一样,浏览器是否有类似的东西?我正在尝试这样做,以便可以将用户详细信息存储到我的数据库中.因此,我们可以找出一个用户使用哪个浏览器访问我的PHP网站.我可以将这样的ID存储到php变量中吗?

I am looking a way to store unique ID of web browsers in PHP? I searched everywhere..but couldn't find any useful things. First of all, does web browsers have a unique ID or something like that to identify them??? Like the computers have a unique IP address, does browsers have anything like that?? I am trying this so that I can store user details into my database. So, we can find out a user used which browser to access my PHP website. Can I store such an ID to a php variable?

例如Web浏览器的$x= ID.

推荐答案

当用户访问您的网站时,您会知道他的IP,浏览器,操作系统和其他内容.您需要知道下一次相同用户访问您(相同的IP,可能使用相同的登录名)是否使用相同的浏览器.这可以通过两种方式实现:

When a user visits your site you know his IP, browser, OS and other stuff. You need to know if the next time the same user visits you (same IP, same login perhaps) is using the same browser. This can be achieved in two ways:

a)创建一个cookie,将其存储在浏览器和您的数据库中,然后将每个具有该cookie的访问者与您现有的cookie表进行比较以识别他.如果Cookie的有效期很长,它将不会在会话中丢失,并且对于每个浏览器都是唯一的.但是如果用户清除cookie,它将丢失.

a) Create a cookie, store it in the browser and in your DB, then compare every visitor that has that cookie against your existing cookie table to identify him. If the cookie has a very long expiration time it won't be lost across sessions, and will be unique to each browser. But it will be lost if the user clears cookies.

b)将字符串存储在浏览器的本地存储中.该方法与cookie方法几乎相同,但是没有数据的有效期,并且删除它比清除cookie更可取.

b) Store a string in the browser's local storage. This works pretty much the same as the cookie method but there's no expiration date for the data, and it's thougher to remove it than to clear cookies.

还有其他方法,例如组合不同种类的cookie以提供冗余.我记得一个名为Evercookie的项目,它做了类似的事情.我相信现在已经几乎废弃了.

There are other methods, like combining different kind of cookies to provide redundancy. I remember a project called Evercookie that did something like that. I believe it's pretty much abandoned now.

这篇关于在PHP中获取唯一的Web浏览器ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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