ReactFix
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • React
  • React Native
  • Programming
  • Object Oriented Programming

Thursday, October 27, 2022

[FIXED] How to keep the user logged in after refreshing the page in Reactjs

 October 27, 2022     express, mern, mongodb, reactjs, session   

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
Answer Checked By - - Marie Seifert (ReactFix Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Newer Post Older Post Home

Featured Post

Is Learning React Difficult?

React is difficult to learn, no ifs and buts. React isn't inherently difficult to learn. It's a framework that's different from ...

Total Pageviews

Copyright © ReactFix