Express JS Cookie parser | Cookies in nodeJS and express

For Consultation : +91 9887575540

Stay Connected :

express cookie parser

Environment setup:


What are Cookies in express

  • This is client-side data storage technique.
  • Small data files
  • Data sent back to the client from the server which stored in cookies.
  • Cookie always sent to the server with each request.
  • Also helps in session management.

How to implement Cookies in express

  • Install middleware for cookie parser
  • Npm install cookie-parse –save
  • Create Cookies :

       res.cookie(‘cookiename‘, ‘cookievalue’)

Set Cookies with the expiration time

  • res.cookie(cookiename, ‘value’, {expire: 360000 + Date.now()});
  • Set Cookies expiration time using maxAge property.
  • res.cookie(cookiename, ‘value’, {maxAge: 360000});

Deleting Cookies



Select your currency