How to keep the user logged in after refreshing the page in Reactjs

Issue

I am working on a project and I’ve created a login page. I want to authenticate the user and keep the user logged in until he logs out. How do I do that using React, Express and MongoDB?

Solution

You can use browser’s localstorage and save the userInfo there and when he logs out you can clear the storage. You can check this set localstorage

Or you can make it from the server side with session-express and redis express sesson

Answered By – mustafa zakaria

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published