Using cookies to store data

Cookies are small bits of information that a website can store in a user's browser. They may be used for various purposes, from providing users with a customized and lively experience to surreptitiously tracking their browsing habits.

Cookies can be created by the server backend or the frontend JavaScript. They can then be read or updated by either one of them.


Install a cookie-editing extension such as Edit This Cookie in Google Chrome to interactively experiment with the cookies created in your browser.

Express provides a cookie API using the cookieParser middleware. To enable the cookie functionality in Express, load it before the router middleware:


With this middleware enabled, you ...

Get Express Web Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.