Managing User Authentication and Sessions

Learn how to manage user authentication and sessions in Express using TypeScript and the express-session library.

The express-session library

Now that we have access to the username and password data from the login form, we can set an application variable that can tell our application whether or not the user has been logged in. To do this, we will store the username in a session variable so that it is persisted between application screens. We will make use of the express-session library to handle session storage.

We can configure our application to use this library by updating our main.ts file with the following changes:

Get hands-on with 1400+ tech skills courses.