Detecting a computer using JavaScript

I am creating a webapp and I could use a solution that allows me to uniquely identify the user's computer.

The reason for this is that after the user logs into the application, he can start several sessions (which are stored in mySQL) associated with the application, however, the sessions should be accessible only from the computer into which the session was initiated.

I cannot use cookies, since the application must allow users to close the browser, restart the computer, etc., without risking losing a user session.

At first I thought that I could get something like a serial board. Naah, it won't happen.

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

Then I wondered if all the Chrome installations had some unique browser identifier that I could use? ... Could not find anything useful.

Any great ideas on how to generate a unique string based on the user's computer?

+4
source share
2 answers

You will need to soften your restrictions: even using the digital printing of the browser , you can not guarantee the changed and not lost UID.

My usual solution, which works very well, but without a guarantee, is to send the UID from the server to the browser and save it in localstorage . Please note that a computer user can delete it or change it. But if the user is not your opponent, this works well.

Reasons for preferring localstorage over cookies:

  • no expiration date
  • there are no tools to β€œclean” them, since they were linked to the beginning from the very beginning and, therefore, do not have a reputation for privacy protection cookies.
  • of course a cleaner and cleaner interface for javascript applications.
+7
source

I cannot use cookies, since the application must allow users to close the browser, restart the computer, etc., without risking losing a user session.

Cookies are not lost upon restart. You can use cookies.

+4
source

Source: https://habr.com/ru/post/1445703/


All Articles