How to get unique device id in php?

I'm looking for something that allow me to get devices (pc, Mac, phone and tablet) unique id like a MAC address can be.

I need to track all logins into a protected area but i'm unable to find an unique id with whom I can identify the used device.

I need that because I want the user to register their devices and then let them login only with that. Thanks

asked Feb 7, 2019 at 17:53

1

You can’t really. It would be a huge security/privacy risk to do that. However, there some things that you could do to get close:

  1. Add a cookie to that device with a UUID

  2. Fingerprinting - Use all available browser settings available to JS such as browser agent, installed fonts etc. to build up a unique-ish profile of a device (Note. Apple try to prevent this in the latest version of Safari)

  3. IP address. It’s not perfect but is can do something and there are ways to remove a small degree of obfuscation. This is an example in PHP: How to get Real IP from Visitor?

Combining all of these things together should be able to give you something close to what you want. It may not completely protect it, but it will offer some form of it.

answered Feb 7, 2019 at 18:11

Bilaal RashidBilaal Rashid

7582 gold badges13 silver badges20 bronze badges

JavaScript is a high level programming language which can not help you storing such information. Same applies to PHP as well.

However, you might want to consider making use of cookies to achieve your goal. You can use a cryptographic algorithm and store it in a cookie, and you have a unique identifier.

answered Feb 7, 2019 at 17:58

1

Not the answer you're looking for? Browse other questions tagged authentication password-protection uniqueidentifier mac-address or ask your own question.

  1. function UniqueMachineID($salt = "") {  
  2.     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {  
  3.           
  4.         $temp = sys_get_temp_dir().DIRECTORY_SEPARATOR."diskpartscript.txt";  
  5.         if(!file_exists($temp) && !is_file($temp)) file_put_contents($temp"select disk 0\ndetail disk");  
  6.         $output = shell_exec("diskpart /s ".$temp);  
  7.         $lines = explode("\n",$output);  
  8.         $result = array_filter($lines,function($line) {  
  9.             return stripos($line,"ID:")!==false;  
  10.         });  
  11.           
  12.           
  13.         if(count($result)>0) {  
  14.             $result = array_shift(array_values($result));  
  15.             $result = explode(":",$result);  
  16.             $result = trim(end($result));         
  17.         } else $result = $output;         
  18.     } else {  
  19.         $result = shell_exec("blkid -o value -s UUID");    
  20.         if(stripos($result,"blkid")!==false) {  
  21.             $result = $_SERVER['HTTP_HOST'];  
  22.         }  
  23.     }     
  24.     return md5($salt.md5($result));  
  25. }  
  26.   
  27.   
  28. echo UniqueMachineID();  

How do I find the unique device ID?

Settings. Secure#ANDROID_ID returns the Android ID as an unique for each user 64-bit hex string. It's known to be null sometimes, it's documented as "can change upon factory reset". Use at your own risk, and it can be easily changed on a rooted phone.

How can we assign a unique identifier in PHP?

A unique user ID can be created in PHP using the uniqid () function. This function has two parameters you can set. The first is the prefix, which is what will be appended to the beginning of each ID. The second is more_entropy.

How do I find the device ID of a website?

Safari :.
Go on your website and get optin..
Click right on your mouse pad and inspect..
Click on the Stockage tab..
Click on Local Storage..
Click on the URL ending by "-by.accengage.net".
Your device ID will show up in the field "UDID".

How do you uniquely identify a device in flutter?

If you need only the id of the device that your app is running on, the simplest and quickest solution is to use the platform_device_id package. It works on Android (AndroidId), iOS (IdentifierForVendor), Windows (BIOS UUID), macOS (IOPlatformUUID), and Linux (BIOS UUID).