What's best practices of getting the deviceId in web app by using javascript?

Hi Everyone,

I’m developping web application by javascript. I now want to get the unique ID used to distinguish different PC devices.

The main requirement is the unique ID should be the same when different users logon to the system. And the unique ID should not be changed when the user clear the browser’s data. When the user logon to the web app, we should get the same unique ID. So the unique ID may be relevant with the hardware of the device.

I want to know what is the best practice.If you have any ideas, please tell me. Thanks in advance.