Skip to content

Existing cookie should be deleted when chunking #2009

Closed
@seanparmelee

Description

@seanparmelee

Checklist

Description

While testing the cookie chunking feature that was added in 4.3.0, I ran into an issue. Our flow looks something like this:

  1. User logs into the app (cookie size is < 3500 KB so it's saved as __session)
  2. User performs an action that results in an additional claim being added to the user's session (cookie size exceeds threshold and gets chunked into __session__0 and __session__1)
  3. When retrieving the user's session, the original __session cookie still exists and is returned instead of the chunked cookie.

In v3, the original cookie gets deleted when going from non-chunked -> chunked, which is what I was expecting to happen in v4 as well.

Reproduction

To be able to reproduce, you'll need to start off with a cookie that's just under the chunking threshold and have a mechanism for increasing the size of the cookie (i.e. adding an additional claim). The steps would be something like:

  1. Log in
  2. Verify __session cookie is set
  3. Perform action that results in a larger cookie (i.e. adds an additional claim)
  4. Verify __session__0 and __session__1 cookies are set (and __session still exists)
  5. Perform an action that depends on the additional claim information that was added in step 3.

Additional context

Relevant code from v3: https://github.com/auth0/nextjs-auth0/blob/v3.7.0/src/auth0-session/session/stateless-session.ts#L149-L151

nextjs-auth0 version

4.3.0

Next.js version

15.2.4

Node.js version

22.14.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions