Get device id from browser javascript

If installed as an app on a mobile device or smart TV, you'll probably have a enough access to get a hold of something unique. I wouldn't necessarily go for a Mac address, but different devices will have different unique identifiers you can grab (even just a phone number would be a pretty good bet for a mobile phone).

Browsers, which are the most restricted environment you listed, are a different story.

Short answer, no.

Longer answer, no, but kinda.

There is no way to get any kind of identifier that is truly unique and unchangeable from the client. This means no MAC address, serial number, IMSI, or any of those other things.

You'd have to turn to an approach which advertisers frequently use to track you across the web.

Basically, you scoop up all the information you can access about a user. These things may include user agent string, IP address, OS, and the like. Basically, things that are sent in an HTTP request and/or via JavaScript client-side. By combining these values together, you can create something that's going to be reasonably unique fingerprint, though not guaranteed and will greatly vary by physical environment that users access it by.

For example, if I'm using my computer at home, and I'm all alone, and I have a fixed IP address, then getting my IP address alone will probably point to just me. If I'm in a college library or an office environment though, and pretty much every other computer all uses the same external IP (quite common a lot of times), and all of them are roughly the same amount of up-to-date, then a lot of people will show up all as the same user even if you mix a bunch of different data points together.

Depending on your use-case, it may be "good enough" (which is generally what advertisers go with), but if it you are using it for any kind of auto-access to security, don't do it. It's never going to be anywhere near secure enough for that. If you want to do something like that, at the very least mix it with a cookie and/or session specific values to reduce the risks.

The deviceId readonly property of the MediaDeviceInfo interface returns a string that is an identifier for the represented device and is persisted across sessions.

It is un-guessable by other applications, and unique to the origin of the calling application. It is reset when the user clears cookies. For private browsing, a different identifier is used that is not persisted across sessions.

Value

A string.

Specifications

Specification
Media Capture and Streams
# dom-mediadeviceinfo-deviceid

Browser compatibility

BCD tables only load in the browser

Method 1

If installed as an app on a mobile device or smart TV, you’ll probably have a enough access to get a hold of something unique. I wouldn’t necessarily go for a Mac address, but different devices will have different unique identifiers you can grab (even just a phone number would be a pretty good bet for a mobile phone).

Browsers, which are the most restricted environment you listed, are a different story.

Short answer, no.

Longer answer, no, but kinda.

There is no way to get any kind of identifier that is truly unique and unchangeable from the client. This means no MAC address, serial number, IMSI, or any of those other things.

You’d have to turn to an approach which advertisers frequently use to track you across the web.

Basically, you scoop up all the information you can access about a user. These things may include user agent string, IP address, OS, and the like. Basically, things that are sent in an HTTP request and/or via JavaScript client-side. By combining these values together, you can create something that’s going to be reasonably unique fingerprint, though not guaranteed and will greatly vary by physical environment that users access it by.

For example, if I’m using my computer at home, and I’m all alone, and I have a fixed IP address, then getting my IP address alone will probably point to just me. If I’m in a college library or an office environment though, and pretty much every other computer all uses the same external IP (quite common a lot of times), and all of them are roughly the same amount of up-to-date, then a lot of people will show up all as the same user even if you mix a bunch of different data points together.

Depending on your use-case, it may be “good enough” (which is generally what advertisers go with), but if it you are using it for any kind of auto-access to security, don’t do it. It’s never going to be anywhere near secure enough for that. If you want to do something like that, at the very least mix it with a cookie and/or session specific values to reduce the risks.

Taken From Stackoverflow and Original Author is samanime

Method 2

It is not technically possible to obtain an ID unique to the device, from a browser.

However there is a way to work around this. You can use JavaScript to generate a long ID, which is statistically guaranteed to be unique, such as a GUID (a 128 bit integer). This value can then be stored in the browsers localStorage (or in a cookie), again using JavaScript.

The next time the users opens this page, you can check if a unique ID is found in the browsers localStorage. If found, you known which device this is.

You can also use other information to help indentify the device, such as the IP address, the device’s screen size, and other settings which can be read through JavaScript.

Non of these solutions are guaranteed to work. For example if a browser is in private mode, the data in the localStorage will not persist.

Taken From Stackoverflow and Original Author is Leander

Method 3

There is a NPM package available to resolve this https://www.npmjs.com/package/device-uuid

NOTE: This will give almost 90%-100% uuid across different browser.

Taken From Stackoverflow and Original Author is Subramanian

Faq

how can I get a unique device ID in javascript?

to fix can I get a unique device ID in javascript, There is a NPM package available to resolve this https://www.npmjs.com/package/device-uuidNOTE: This will give almost 90%-100% uuid across different browser.

how do i fix how can I get a unique device ID in javascript?

to fix can I get a unique device ID in javascript, There is a NPM package available to resolve this https://www.npmjs.com/package/device-uuidNOTE: This will give almost 90%-100% uuid across different browser.

Also Read,

  • ReferenceError: AbortController is not defined in Discord.js v13
  • JS Event Handler: Async Function
  • Angular 7: NullInjectorError: No Provider For PagerService

Can I get device ID from browser?

6 Answers. Well after further research, the answer is: No, it's not possible right now to get a mobile device id number from its browser...

Can I get device ID Javascript?

Short answer, no. Longer answer, no, but kinda. There is no way to get any kind of identifier that is truly unique and unchangeable from the client. This means no MAC address, serial number, IMSI, or any of those other things.

How do I find my browser unique device ID?

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 can you identify a uniquely device?

So, you can easily retrieve an unique ID identifying the device. This unique ID can be IMEI, MEID, ESN or IMSI. They can be defined as follows: IMEI for International Mobile Equipment Identity: the Unique Number to identify GSM, WCDMA mobile phones as well as some satellite phones.