Get Unique web browser ID in PHP

14,432

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.

Share:
14,432
Smokey
Author by

Smokey

A software professional with 5.3 years of diverse experience in Software Development.

Updated on June 05, 2022

Comments

  • Smokey
    Smokey almost 2 years

    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?

    for example, $x= ID of the web browser.