DEV Community

Shubham Tiwari
Shubham Tiwari

Posted on

Help Help Help ๐Ÿ˜†

Hello Everyone , i need help in my MERN project
i have created the project and Created a login form and signup form , When i log in , the credentials are checked and the user get logged in and the user Dashboard is shown
But When i refresh the page or the page gets refresh , the user got back to the login/signup page
I want to create a session type something that will make the user logged in even if the page gets refresh and only see the login/signup when the user log out by themselves

THANK YOU

Top comments (4)

Collapse
 
jacksonkasi profile image
Jackson Kasi • Edited

You can store user ID in cookies or localStorage once user login. If anyone( user ) open/ refresh your website, you will request user data by user ID, and handle the user data( ex: using redux or something ) on your website. ๐Ÿ™‚

Collapse
 
shubhamtiwari909 profile image
Shubham Tiwari

So on log out i have to clear the cookies?

Collapse
 
jacksonkasi profile image
Jackson Kasi • Edited

If the user logout, you should definitely clear cookies, else don't!

Thread Thread
 
shubhamtiwari909 profile image
Shubham Tiwari

okay Thank you