Thanks to visit codestin.com
Credit goes to github.com

Skip to content

A single-file Express.js learning project demonstrating how to set, read, verify, and clear regular & signed cookies using `cookie-parser`.

License

Notifications You must be signed in to change notification settings

Misba0019/express-cookie-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🍪 Express Cookie Demo

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.


Features

  • Set and retrieve regular cookies
  • Create and verify signed cookies (tamper detection)
  • Clear cookies from the client
  • Minimal, easy-to-run setup

Routes & App Flow

  • GET /greet – Greets the user using the name cookie (defaults to "User")
  • GET /setname – Sets name and fish cookies
  • GET /getsignedcookie – Sets a signed cookie fruit
  • GET /verifycookie – Displays both signed and unsigned cookies in JSON format
  • GET /clearcookies – Clears all cookies set in this demo

Technologies Used

  • Node.js
  • Express.js
  • cookie-parser
  • dotenv

Getting Started

1. Install Dependencies

npm install

2. Set Environment Variables

Create a .env file in the project root:

COOKIE_SECRET=your_cookie_secret_here

3. Start the Server

node index.js

The app will be available at http://localhost:3000/products.


Learning Outcomes

  • Understanding signed vs unsigned cookies
  • Using Express middleware effectively
  • Following best practices with environment variables

License

This project is licensed under the MIT LICENSE - see the LICENSE file for details.

About

A single-file Express.js learning project demonstrating how to set, read, verify, and clear regular & signed cookies using `cookie-parser`.

Topics

Resources

License

Stars

Watchers

Forks