npm cookie-parser

  1. Install cookie-parser package using npm:
npm install cookie-parser
  1. Require cookie-parser in your Node.js application:
const cookieParser = require('cookie-parser');
  1. Use cookie-parser middleware in your Express application:
app.use(cookieParser());
  1. Access cookies in your route handlers or middleware:
app.get('/example', (req, res) => {
  // Access cookies using req.cookies object
  const myCookie = req.cookies.myCookie;
  res.send(`Value of myCookie: ${myCookie}`);
});
  1. Set cookies in your route handlers or middleware:
app.get('/set-cookie', (req, res) => {
  // Set a cookie using res.cookie method
  res.cookie('myCookie', 'cookieValue');
  res.send('Cookie set successfully');
});
  1. Configure options for cookie-parser:
// Example with options
app.use(cookieParser({
  // Options go here
}));

Note: Refer to the official documentation for cookie-parser for more details on available options and usage: https://www.npmjs.com/package/cookie-parser