What is the remember_me
feature for?
When you are working with sessions in Laravel, you can have the
need to enable the user's session to remain active,
that is, even if it moves from the browser tab or closes the
browser for example your login is maintained.
To achieve this, your users table must have a column
remember_token
That in fact in migrations you can observe it with this structure, this column you will find it in the migration users
:
$table->rememberToken();
If you do that in your login system, that is to say in your HTML there should be
<input type="checkbox" name="remember">
After that you will see in your browser the following route:
1.- open the mode of debug
or the tools of desarrollador
2.- go to the tab resources
3.- go from the left side to cookies
In this last location you will find that for each time a user starts a session, two relevant data are generated:
XSRF-TOKEN //esta es una cookie que genera laravel para validar las peticiones que
hace el usuario
laravel_session //ayuda a identificar la instancia de sesión creada por cada
usuario activo dentro del sistema
both are a string of text and numbers that validate each request of the user that is interacting in the system, so that the requests that the user makes through the HTTP verbs are accepted
Now to enable the framework to help remember the login and the user is not left to interact within
The following is done
If at the moment of the session you select the previous checkbox, laravel will create a:
remember_NHYi87Buyt67Tbhh
That is nothing other than a string that helps to identify as valid
the beginning of the session so as not to close it and require the credentials of
new; so that although the user closes the browser if it returns
to open the session will remain active until the lifetime of the
cookie is finished
For example if you go to the route: appname / config / session.php you will realize that the maximum time of life assigned to you by default is 120 minutes