vercel / vercel/next.js

Multiple cookies with the same name are not returned by "(await cookies()).getAll()"

Open
#95,265 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Cookies
Dominant language
JavaScript
Stars
142k
Forks
32.4k
Avg merge
2d 14h
Merged PRs (30d)
351

Description

Link to the code that reproduces this issue

https://github.com/Lebuin/repro-nextjs-duplicate-cookies

To Reproduce
  1. Start the application in development mode
  2. In a terminal, run curl -H "Cookie: sessionid=a; sessionid=b" http://localhost:3000
Current vs. Expected behavior

According to the docs:

Getting all cookies

You can use the (await cookies()).getAll() method to get all cookies with a matching name. If name is unspecified, it returns all the available cookies.

In my reproduction, I'm passing 2 cookies with the same name "sessionid". I expect getAll() to return an array containing both values. Instead, it only returns the last encountered value.

  • Expected: {"Cookie header":"sessionid=a; sessionid=b","All cookies":["sessionid=a", "sessionid=b"],"Matching cookies":["sessionid=a", "sessionid=b"]}
  • Actual: {"Cookie header":"sessionid=a; sessionid=b","All cookies":["sessionid=b"],"Matching cookies":["sessionid=b"]}

The fact that the method getAll(name) exists at all, makes me think that my expectations do match to way the cookie store was designed.

Provide environment information
Operating System:
  Platform: linux
  Arch: x64
  Version: #124-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 13:00:45 UTC 2026
  Available memory (MB): 15887
  Available CPU cores: 8
Binaries:
  Node: 24.14.1
  npm: 11.11.0
  Yarn: N/A
  pnpm: 10.14.0
Relevant Packages:
  next: 16.3.0-canary.70 // Latest available version is detected (16.3.0-canary.70).
  eslint-config-next: N/A
  react: 19.2.7
  react-dom: 19.2.7
  typescript: 5.9.3
Next.js Config:
  output: N/A
Which area(s) are affected? (Select all that apply)

Cookies

Which stage(s) are affected? (Select all that apply)

next dev (local), next start (local)

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the linked reproduction repository and sending the documented curl request with duplicate sessionid values. Trace the cookies() API and its getAll() behavior, then inspect nearby cookie tests if available. Done means getAll() and getAll("sessionid") preserve both values from the Cookie header without regressing single-cookie behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nextjs
Domain
backend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.