Heading not updating after logging in.
I have 2 variants of the handleSuccessfulLogin function but none of them work. I want to the update the heading in stats.html when the the user is logged in. It does direct to the page after logging in but doesnt add the "Welcome {username} on that page.
6 Replies
when you use window.location the page is reloaded and your javascript state and any modifications you made to the dom are lost
you'll have to check if the user is logged in somehow on each fresh page load and change the dom accordingly. Considering this is all front-end, you can get away with just checking if the login cookie from the backend exists and changing the DOM accordingly
Sorry but i don't know how to check on each page if the user is logged in or not. Can you please maybe tell me the steps to do it rather the full code?
you're storing the username in sessionStorage:
On each page load, you can check if that is still set, and then change the DOM accordingly
Alright, thanks
It works now
Thanks a lot.
always glad to help!