1

I came across an issue today with express, assume we set several cookies, when I use request.headers only one cookie is returned:

cookie: 'userSession=123'

for example, not only can't I use request.headers.cookie 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?

Ilja
  • 44,142
  • 92
  • 275
  • 498
  • This will work with multiple cookies: http://stackoverflow.com/a/3409200/2797034 though if you are only receiving one cookie, its likely because that is all that is sent in the request. – wrxsti Jul 06 '16 at 14:53

1 Answers1

3

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

C.Raf.T
  • 373
  • 4
  • 13