Local Storage of Loggedin User Details

Hi,

Where is the best place to store the name of the loggedin user to display it on the frontend?

I am currently storing it in the cookie session but I am sometimes encountering the case where the user is logged in but the stored name is not available.

PS: I can not store it in the local storage as we might have different users logged in from the same device.

Thank you in advance

Why not create a logged user details server action, and include it on all your pages?
Then you can bind logged user info on your pages.

You can just include it in a SSI and reuse it on all your pages.

2 Likes

Because i had faced the issue of cached user details when someone loggedout and another one loggedin. But i will follow your suggestion and releoad the serverconnect cache on login. Thank you

Perhaps as an alternative you could check the cookie value (from a SSI) and redirect to login if the cookie value is not set/ set correctly, personally i would go for Teodors suggestion but this may work as an alternative

2 Likes