Cookies — Techniques · NestJS

Remember a visitor between requests: parse cookies with cookie-parser, read them through custom decorators, set a plain cookie for a theme and a signed one for a favourite cat that nobody can forge.

What you will learn

Read the theory for Cookies

All Techniques lessons

All NestJS courses

loading types…

What you'll learn

  • Register cookie-parser with a secret and read cookies from the request through a custom parameter decorator
  • Set and clear cookies from a handler with @Res({ passthrough: true }), choosing httpOnly and the other options deliberately
  • Explain what a signed cookie guarantees, and read one from signedCookies rather than cookies