Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does remember me feature work on a website?

Tags:

web

I wish to integrate a remember me feature on my website. Can someone please explain the underlying concept and code behind it?

like image 507
dorado Avatar asked Jul 14 '14 19:07

dorado


People also ask

How does the Remember Me feature works?

The remember-me feature typically works by generating a unique cookie, associating it with the user in the database, and adding a persistent cookie (i.e. a cookie which is saved on disk by the browser) to the response once the user is logged in.

Why is a Remember username feature on a webpage?

Your web browser may have a setting that allows it to remember and pre-fill your login credentials when you return to a website after logging out, but the "Remember Me" feature works in the background, and only if you have not logged out from the site.

Are Remember Me features safe?

The “remember me” option is safe to use on computers and devices that you can trust to protect your browser. It doesn't defeat the purpose of 2FA because the convenience it provides is limited to each computer and browser that you choose to use it on.


1 Answers

Typically it's done via a cookie. Upon user login, a cookie is set with a specific (cryptographically secure) code (typically NOT including the user's password or any derivation thereof, but instead a hash that is used to look for the user), which is sent with each request. The website first checks if a user is logged in, and if not it looks for that cookie and tries to parse the data. If the data matches/is valid, the user is automatically logged in successfully. The cookie can be set for a number of days (such as 30) and deleted when the user logs out.

like image 57
Haney Avatar answered Nov 15 '22 09:11

Haney