Cookie-parser is a middleware for Express.js that enables parsing and handling HTTP cookies. It is widely used in the Node.js community, with over 8500 projects utilizing it in the npm registry. The latest version is 1.4.6, which was published 2 years ago.
Cookie-parser interprets the Cookie
header into a JavaScript object, storing it in req.cookies
. Optionally, it supports signed cookies by assigning req.secret
for use by other middleware. To install cookie-parser, simply run npm i cookie-parser
.
The API includes functions like JSONCookie()
and JSONCookies()
for parsing JSON cookies, as well as signedCookie()
and signedCookies()
for handling signed cookies.
An example of using cookie-parser in an Express application involves importing it, creating an Express instance, using the middleware, and defining a route to log cookies and signed cookies. To start the server, run npm start
.
Cookie-parser is open-source and released under the MIT License.