How to keep user logged in React JS || Stay logged in using window.localstorage() React JS Tutorial

preview_player
Показать описание
Hello guys,

Check out this amazing cloud platform:
ZEGOCLOUD SDK provides easy video call SDK, voice call SDK, live streaming SDK and chat SDK for real-time interaction.
#zegocloud #uikits #sdk #api #react

In this video I have explained how can you keep user logged in in your website until he presses logout. Store the session in localstorage.
I have explained all the logic and steps.
Thank You.

How to keep user logged in.
Stay Logged in.
keep user logged in, in website until he presses logout.
Рекомендации по теме
Комментарии
Автор

Just what I was looking for. Thank you!

Javier-qpbm
Автор

Thank you for this. Very simple and well explained. Looking forward to your future videos!

killmongr
Автор

Hi its really a good approach. It's will fail if token has expires on backend server....then there is no point ok We can do it in a better way by sending a request to sever to validate if the token is still there.. On sever... Its my point of view... Share your

saravanasai
Автор

what if user add the url of login page manually in the url bar, and hit enter will it comeback to the login page or styed login, i mean if the token is not expire then it should redirect the user to profilepage(loggedIn state), i am trying to acheive this functionality, but did not work, will anyone plz help me

zainak
Автор

what if i log out, then go to localstorage and create a key-value pair {isLoggedIn:true}? Is it a good approach?

tejaslotlikar
Автор

but if we close browser it clears the local storage

sachinpandey
Автор

You are storing token in localstorage what's the need of storing in localstorage like we can create a useState in useContext by creating a context and our usestate contain token and settoken when I get response of token from backend i'll update the state what's the need of localstorage

codesetter
Автор

Where do you store the user info that is loged in, like user name and email ?

josepazmino