Login Error

Hello friends, I have created a MERN stack website with a login feature, and the login feature is fully implemented using Auth0. The login is working fine, but when I refresh the page, it automatically logs me out. Can anyone tell me why this is happening and how I can solve this problem? I have been working on this for the past 3-4 days, but I haven't been able to solve the problem yet. Please, if anyone can help me, it would be greatly appreciated
3 Replies
Tenkes
Tenkes3mo ago
Show some code
glutonium
glutonium3mo ago
u need to use session I believe using session u keep track of user log in, i.e if the user has previously logged in or not when user lands on the page it checks the session, checks if user has previously logged in , if so then it automatically logs the user in at least that's how I did it when I was once making backend using flask also once a user logs out, u clear the session
Satcha Takam
Satcha Takam3mo ago
when the user first logged in you should store the token or what ever you using to confirm that a user has logged in either in cookies or local storage (ps: I prefere localStorage), you would also create a handler in a useEffect hook that would check for a token in your localStorage berfore the app renders like that the user will not login at every page refresh. I hope it helped you
Want results from more Discord servers?
Add your server
More Posts