From 20270259ae42f308dbaa8a95557a5738346a1834 Mon Sep 17 00:00:00 2001 From: Hashim Khan Date: Mon, 27 Jul 2026 02:15:19 +0500 Subject: [PATCH] docs: clarify empty cookies when Cookie header is absent Document that req.cookies and req.signedCookies are always empty objects when no Cookie header is sent, so callers do not need to guess between {}, false, or undefined. Fixes #107 --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b8ecd7b..f962dff 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,9 @@ Create a new cookie parser middleware function using the given `secret` and The middleware will parse the `Cookie` header on the request and expose the cookie data as the property `req.cookies` and, if a `secret` was provided, as the property `req.signedCookies`. These properties are name value pairs of the -cookie name to cookie value. +cookie name to cookie value. When no `Cookie` header is present (or the header +is empty), both `req.cookies` and `req.signedCookies` are set to empty objects +(never `undefined` or `false`). When `secret` is provided, this module will unsign and validate any signed cookie values and move those name value pairs from `req.cookies` into `req.signedCookies`.