CookieParser vs req.cookies expressjs

Viewed 7060

When I read about req.cookies in expressjs docs,

When the cookieParser() middleware is used this object defaults to {}, otherwise contains the cookies sent by the user-agent.

And when I read about CookieParser middleware,

Parses the Cookie header field and populates req.cookies with an object keyed by the cookie names.

So, req.cookies says if I use CookieParser, it will be set to {}, but CookieParser says it will populate req.cookies.

My question is Why do we need CookieParser, if req.cookies itself gives the cookies?

2 Answers
Related