Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Identify computer using JavaScript

Tags:

javascript

I'm building a webapp, and I could use a solution that allows me to uniquely identify the users computer.

The reason for this is, that once the user is logged into to the application he/she can start several sessions (which is stored in mySQL) related to the app - however, the sessions should only be available from the computer in which the session was initiated.

I cannot use cookies, since the application should allow users to close the browser, restart the computer etc etc., without any risk of loosing the users session.

At first I thought I would be possible to get something like a motherboard serial. Naaah, not going to happen.

Then I thought of generating an MD5 hash based on users remote address + MAC address, until I found out that this is only possible using older versions of IE with ActiveX.

Then I came to think if all Chrome installations have some sort of unique browser ID I could use? ... Haven't been able to find anything helpful.

Any great ideas on how to generate an unique string based on the users computer?

like image 693
EibergDK Avatar asked Nov 13 '12 07:11

EibergDK


2 Answers

I cannot use cookies, since the application should allow users to close the browser, restart the computer etc etc., without any risk of loosing the users session.

Cookies are not lost when the compute restart. You can use cookies.

like image 39
gdoron is supporting Monica Avatar answered Nov 13 '22 16:11

gdoron is supporting Monica


You'll have to relax your constraints : even by using the browser digital print, you won't be able to have a guaranteed not changed and not lost UID.

My usual solution, which works very well but with no guarantee, is to send from the server to the browser an UID and to store it in localstorage. Note that a computer savvy user can remove it or change it. But if the user isn't your foe, this works well.

The reasons to prefer localstorage over cookies are :

  • no expiration
  • no tools to "clean" them, as they were origin-bound from the start and thus haven't the privacy-breach reputation of cookies
  • of course the cleaner and saner interface for javascript applications
like image 112
Denys Séguret Avatar answered Nov 13 '22 18:11

Denys Séguret