Remember me in Laravel

2

I want your guidance, can someone explain to me what is the usefulness of Remember me in Laravel?

The code I have works, saves the token on BD and everything, but I've tried and I have not seen any use.

Could you please explain what is the utility? what is it for? How can I prove its usefulness?

Really, I know it seems like a question from an apprentice but the truth is what I tell you, I have not seen any use.

    
asked by jose angarita 04.10.2018 в 21:50
source

2 answers

1

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

    
answered by 04.10.2018 / 22:16
source
1

At the time I did not know what Remember Me was for ... I will explain it to those who do not know it.

Remember me in Laravel, what it does is keep the session active, the sessions have in Laravel by default 120 minutes of life, if the session cookie dies the session is closed.

If you click Remember me, the session never dies and remains active, until you decide to log out on your own.

Greetings.

    
answered by 22.10.2018 в 05:06