So, I’ve been reading the Passport.js documentation when I reached the serialize and deserialize section. I tried to understand these two methods but I couldn’t get my head around them. So can anyone please tell me why we need to use them? what is the purpose behind using them?
One more thing, it would be so much appreciated if you tell me what sessions are and how they basically work (I think I couldn’t understand serserializeUser and deserializeUser methods because of lack of understanding sessions).
Sessions are a way of temporarily persisting state (data) between requests. This is commonly used to ‘remember’ that a user is logged in. Check out this SO answer for more of an explanation of sessions (and cookies).
As for the functions
deserializeUser, there’s a good explanation here. The TL;DR is that the functions tell Passport.js how to get information from a user object to store in a session (serialize), and how to take that information and turn it back into a user object (deserialize).
Hope that helps
Thanks man. In the next times, I think I will just post in the forums and then post a link in the general slack group. Wouldn’t that be better than asking directly in slack?
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.