Skip to content

docs: clarify empty cookies when Cookie header is absent - #170

Open
Hashim1999164 wants to merge 1 commit into
expressjs:masterfrom
Hashim1999164:docs/clarify-empty-cookies-107
Open

docs: clarify empty cookies when Cookie header is absent#170
Hashim1999164 wants to merge 1 commit into
expressjs:masterfrom
Hashim1999164:docs/clarify-empty-cookies-107

Conversation

@Hashim1999164

@Hashim1999164 Hashim1999164 commented Jul 26, 2026

Copy link
Copy Markdown

Summary

  • Document that when no Cookie header is sent (or it is empty), req.cookies and req.signedCookies are empty objects rather than undefined or false.
  • Matches the existing middleware behavior of initializing both properties before returning.

Fixes #107

Test plan

  • Confirmed in index.js that both properties are set to Object.create(null) before the early return when req.headers.cookie is missing
  • Spot-checked with a minimal middleware call and no Cookie header: both properties are objects with zero keys
  • README wording looks clear to a first-time reader of the API section

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 expressjs#107
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

In readme, please clarify what req.cookies and req.signedCookies will be when no cookies are received.

1 participant