Skip to content

Cleaning locals.user #19

Answered by Sirneij
rushanepam asked this question in Q&A
Dec 1, 2023 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

Hi rushanepam,

In the logout function, we are not setting locals.user = null because it's not required. What was required was clearing the cookie since that was what validated the requests sent to the server each time a request was made. However, you can "clean" it up if you want but currently, when a user logs out and the cookie is "eaten", local.user automatically becomes empty.

The handle function is called every time a request is made to sveltekit's server. However, as long as the local.user still has some data, it won't fetch the user's details from the backend server. This is what these lines do.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@rushanepam
Comment options

@Sirneij
Comment options

Answer selected by rushanepam
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants