Many users want a possibility to autologin when they return to my website. I just finished to implement it and I have read several artcles about this question. For example, here. I use different tokens, hashes, etc and regularry update autologin cookies un DB information associated with these cookies.
The main problem is that if user A have a autologin cookie in his computer A, user B can stole this cookie and place it on another computer B and successfully autologin to the user's A account.
My main question is:
1. How to make sure that the person who enters with autologin cookie, really is user A from computer A and not user B from computer B?
There are 2 ways how to prevent it, but none of them are very useful:
To check user's IP address. Mobile Internet users may have a different IP address every 5 minutes. So, this is not very useful. I just implemented an option that users can check a box if they want to allow autologin only from their recent IP address.
To check the user-agent. I have implemented this and tested on Firefox. Worked fine. Then I started to test it on Chrome and almost every day my autologin cookie was not valid because Chrome updates almost every day and useragent changes.
2. Is there any easy way how to remove the browser version number from user agent so that I can check just the browser, etc but not the browser version number?
I'am logged in on Facebook for a long time - probably 1 year. Have many times updated the browser but my autologin cookie is still valid. Does it mean that they don't check the user agent?
3. Are there any other methods how to make sure that user who enters my website really is user A and not someone else?