Skip to content

Add CookieStore #4525

Closed as not planned
Closed as not planned

Description

@Richienb

This would solve...

Storing cookies between HTTP requests.

The implementation should look like...

A pure/without-side-effect form of CookieStore.
Then, userland request libraries can accept a CookieStore instance as an option.

I have also considered...

  1. Polyfilling the CookieStore instance.
  2. got (userland request library) provides server-side cookie support with tough-cookie, which exposes a CookieJar that manages cookies, where an instance is passed straight to got.

Additional context

Moved from nodejs/node#59799 (comment)

Activity

  1. added
    enhancement
    on Sep 7, 2025
  2. marked Add CookieStore node#59799 as a duplicate of this issue on Sep 7, 2025
  3. KhafraDev commented on Sep 7, 2025

    @KhafraDev
    Member

    I had implemented this a few years ago (#1441) but I gave up. The API is terrible and it conceptually does not work in a server environment. As mentioned, there's no global cookieStore and there's no origin handling - this is a glorified (or rather shittified) re-implementation of the existing cookie parsing undici already has.

    If we implemented this it would neither function nor behave as other implementations. It wouldn't be hard to implement, but why should we implement it?

  4. Richienb commented on Sep 8, 2025

    @Richienb
    Author

    why should we implement it?

    When server request libraries implement cookie support, they have to just pick a conventional userland cookie library and only support that.
    I would like if we could centralize this functionality in Node itself, and across other server-side JavaScript platforms, so implementing CookieStore seems like a logical way to do this.

  5. metcoder95 commented on Sep 8, 2025

    @metcoder95
    Member

    I'm curious, what are the use cases we can enable for servers having support for cookies; I imagine doing mimic of browser behaviour (e.g. web scrapper), but I'm having troubles to see more use cases beyond that.

  6. Richienb commented on Sep 8, 2025

    @Richienb
    Author

    I imagine doing mimic of browser behaviour (e.g. web scrapper)

    Yes, browser behaviour seems to be the main use case, when surveying over https://github.com/salesforce/tough-cookie/network/dependents

  7. KhafraDev commented on Sep 8, 2025

    @KhafraDev
    Member

    I would like if we could centralize this functionality in Node itself, and across other server-side JavaScript platforms, so implementing CookieStore seems like a logical way to do this.

    There's a reason other platforms have not implement the spec. Its only saving grace is that document.cookie in the browser is far worse.

    Implementing CookieStore (a bastardized version of it) is only half the issue because we would still have to implement our own CookieStore manager that no other platform implements. So we wouldn't have a good implementation of CookieStore and we wouldn't match other platforms. Doesn't tough-cookie work on other serverside environments already?

  8. Richienb commented on Sep 8, 2025

    @Richienb
    Author

    Ok, looks like tackling this issue should be more upstream so that we can hope to get the benefit of everyone using the same thing.

  9. Uzlopak commented on Sep 9, 2025

    @Uzlopak
    Contributor

    to be honest, the current cookie parsing logic is anyway crap because we "copied" it from deno.

  10. KhafraDev commented on Sep 18, 2025

    @KhafraDev
    Member

    I don't see a way to move forward on this re: previous comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions