Question App in Nodejs, Pug,cookie-parser, setting cookies 5

Lesson Summary

In this lesson we are learning about cookies and how we can use them to remember our state within our app. We learn that the http protocol is a stateless protocol which means the client and the server do not remember the states of each new request. We learn that one of the ways around this is using cookies to store state. We add a cookies using res.cookie() and provided a name and value withing the parameters. We use res.cookie("username", req.body.username) to store the username entered into our form into a cookie we can access using the name "username". We then access the cookie if it exist using req.cookies.username.

Subscribe To Monthly Newsletter. Chance to Win Monthly Prizes

* indicates required