A backend learning project demonstrating how to set, read, verify, and clear both regular and signed cookies in an Express.js server using the cookie-parser middleware.
- Set and retrieve regular cookies
- Create and verify signed cookies (tamper detection)
- Clear cookies from the client
- Minimal, easy-to-run setup
- GET
/greet– Greets the user using thenamecookie (defaults to "User") - GET
/setname– Setsnameandfishcookies - GET
/getsignedcookie– Sets a signed cookiefruit - GET
/verifycookie– Displays both signed and unsigned cookies in JSON format - GET
/clearcookies– Clears all cookies set in this demo
- Node.js
- Express.js
- cookie-parser
- dotenv
npm installCreate a .env file in the project root:
COOKIE_SECRET=your_cookie_secret_herenode index.jsThe app will be available at http://localhost:3000/products.
- Understanding signed vs unsigned cookies
- Using Express middleware effectively
- Following best practices with environment variables
This project is licensed under the MIT LICENSE - see the LICENSE file for details.