Integrating Express-Session and Passport.js | Node Auth Tut - Part 5

June 20th 2017 | 13.5k views

We know sessions are a place in which we can store data on our app's backend. We also know that session packages typically return to the user a cookie that associates them with their corresponding session. However, what we don't know is how to use a session to "log a user in" to our app.

When it comes to logging a user in, we need to have some way to test whether or not the cookie within a user's browser matches up with the session created within our app's backend. Integrating this yourself can be a little tricky, but it's much easier when using something like Passport.js. Passport.js is able to determine whether or not a user is logged in based on the sessions our app possesses. Learn how to combine Passport.js with express-session to finally create a user that's deemed "logged in."