How does an express session work?

Asked

Viewed 573 times

-1

I have a problem logging into my application. If a user logs in, they log in to everyone who visits the site. Could you explain to me how a session works so I can understand better?

1 answer

0


Friend, when the user logs into your application a cookie is saved in the client side to identify that this user is logged in.
As long as the cookie is valid the application understands that the user is logged in, as soon as the cookie expires the application must request to log in again.

The estate maxAgeof the cookie is who informs when that cookie should expire, by default it has no value, but you can add that time in milliseconds, so when the cookie is created it will take the server time and add the milliseconds you entered to generate the information of when that cookie should expire.

If you think it necessary, you can read documentation.

  • Show, clarified a lot. One more question, has how I store data in a session?

  • @XTRADEXTRADE has yes, to access use the session property req.session

, give a look at the documentation I gave you that has an example of how to use this property! Note: if the answer has solved your question, please consider marking it as correct to help other people with the same question!

  • Thank you very much!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.