3

How can I access the cookies on the sequence in Loopback 4 ? I need to validate a session that is sent in a cookie, how can I access its value in loopback 4?

Thanks a lot.

Juan Pablo Fernandez
  • 2,408
  • 3
  • 18
  • 32

1 Answers1

2

In your sequence file, you have your request like this:

const {request, response} = context;

You can then use request.headers.cookie to get your cookie. This is the simple answer.

But to validate your session, I think it would be better to implement a middleware in your sequence and then do your authentication there. You can get some inspiration from there: https://github.com/strongloop/loopback-next/tree/master/packages/authentication

hanego
  • 1,595
  • 1
  • 14
  • 27