developerasun / myCodeBox-web

Open source code box for web developers.
Apache License 2.0
5 stars 0 forks source link

NPM : cookie parser #119

Open developerasun opened 2 years ago

developerasun commented 2 years ago

research : read cookie parser in NPM

read this

Parse Cookie header and populate req.cookies with an object keyed by the cookie names. Optionally you may enable signed cookie support by passing a secret string, which assigns req.secret so it may be used by other middleware.

cookieParser(secret, options) Create a new cookie parser middleware function using the given secret and options.

  1. secret : a string or array used for signing cookies. This is optional and if not specified, will not parse signed cookies. If a string is provided, this is used as the secret. If an array is provided, an attempt will be made to unsign the cookie with each secret in order.

  2. options : an object that is passed to cookie.parse as the second option. See cookie for more information. decode a function to decode the value of the cookie

The middleware will parse the Cookie header on the request and expose the cookie data as the property req.cookies and, if a secret was provided, as the property req.signedCookies. These properties are name value pairs of the cookie name to cookie value.

refererence