简体   繁体   English

是否可以获取唯一的ID,以区别于计算机和另一个计算机?

[英]Is there possible to get unique id for differentiate from computer to another?

I m new to php, but i know basics. 我是php的新手,但我了解基本知识。 still im learning in php. 仍在学习中的PHP。

In between gap, May i know, Is there possible to get unique id for differentiate from computer to another by using php? 在间隙之间,我是否可以知道,是否有可能通过使用php获得唯一的ID,以区别于计算机和另一个计算机?

Any suggestions would be highly appreciated. 任何建议将不胜感激。

Thanks. 谢谢。

A computer doesn't have a permanent unique id that can be read by php. 一台计算机没有可以被php读取的永久唯一ID。

So depending on your requirement you can try IP address, but this is likely to change over time. 因此,根据您的要求,您可以尝试IP地址,但这很可能会随着时间而改变。 So only for a short period of time you can use this information. 因此,只能在短时间内使用此信息。

If you want to know for a longer period of time, when the user comes back to your page, the best way to do this is by assigning your own unique id in a cookie to the browser. 如果您想长时间了解,当用户返回您的页面时,最好的方法是在Cookie中为浏览器分配自己的唯一ID。 This cookie will remember which computer is which. 该cookie将记住哪台计算机。

You can set cookie to detect computer and also can detect IP. 您可以设置cookie以检测计算机,也可以检测IP。 Now a days most of the ISPs uses dynamic IP address. 现在,大多数ISP使用动态IP地址。 Dynamic IP changes when client disconnect and reconnect internet connection. 当客户端断开连接并重新连接Internet连接时,动态IP会更改。 So cookie is the best way to detect a computer. 因此,cookie是检测计算机的最佳方法。

To set cookie use: setcookie('cookiename','cookievalue',time()+3600,'/','.example.com',0,1); 设置cookie使用: setcookie('cookiename','cookievalue',time()+3600,'/','.example.com',0,1);

To retrive cookievalue: $_COOKIE['cookiename']; 检索cookievalue: $_COOKIE['cookiename'];

To get IP: $_SERVER['REMOTE_ADDR']; 要获取IP: $_SERVER['REMOTE_ADDR'];

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

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