Cleaning locals.user #19
-
Hi Sirnejj, Sorry for a stupid question, but still: when user logs out - where do we clean up the And another question would be: if handle fn inside hooks.server.ts gets called every request to a sveltekit's server, does it mean that we will request for user details ( Thank you in advance |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi rushanepam, In the logout function, we are not setting The handle function is called every time a request is made to sveltekit's server. However, as long as the |
Beta Was this translation helpful? Give feedback.
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.