From the course: Building a Website with Node.js and Express.js
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Add a session management middleware
From the course: Building a Website with Node.js and Express.js
Add a session management middleware
- [Instructor] While we are at fleshing out the application logic, I want to add one more piece of middleware that is common to web applications, and that we will also need a bit later. HTTP is stateless, this means that it doesn't recognize a user between requests. To persist data for a user from request to request, we need sessions. In my course Advanced Express, I provide detailed insights into how sessions work. For this course, I keep it short, and just show you how to install a proper session management system, and how to use it. There are various different session modules for express. We will use cookie sessions. Cookie sessions store the data we want to persist for a user encrypted on the client, this needs to be encrypted, because we don't want the user to be able to see and manipulate what we store in that session. The encryption hides it from them. To get started we will now install the cookie session…