Get Unique web browser ID in PHP

后端 未结 2 1417
滥情空心
滥情空心 2021-01-03 11:20

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

相关标签:
2条回答
  • 2021-01-03 11:53

    You can use the browscap library and then make an md5 of the browser information:

    Uses GaretJax/phpbrowscap

    $bc = new \phpbrowscap\Browscap('data/');
    $current_browser = $bc->getBrowser(null,true);
    $str = json_encode($current_browser);
    $browser_id = md5($str);
    
    0 讨论(0)
  • 2021-01-03 11:57

    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) 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) 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.

    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.

    0 讨论(0)
提交回复
热议问题