Ilja Ilja - 1 year ago 159
Node.js Question

Get specific cookie from request headers (express)

I came across an issue today with express, assume we set several cookies, when I use

only one cookie is returned:

cookie: 'userSession=123'

for example, not only can't I use
as it is unreliable (users can have several cookies set), but I can't parse it into a JSON object (this is invalid json) nor can I select this cookie specifically, which leads to a subquestion, is this how we get cookies from express response, through headers?

Answer Source

you can use cookieParser() from $ npm install cookie-parser

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download