Skip to content

impl CookieStore? #42183

Closed as not planned
Closed as not planned

Description

@jimmywarting

What is the problem this feature will solve?

Cookie parsing and serializing is tuff. Most often you need a cookie plugin for whatever reason and dose are downloaded milion of times / week on npm

Adding a memory based CookieStore that can be constructed using new CookieStore() in some form would be beneficial. I'm just imagining http, https, http2 and fetch to have support for passing in own custom CookieStore parameter somewhere for it to be used somehow

Activity

  1. added
    feature request
    on Mar 2, 2022
  2. moved this to Pending Triage in Node.js feature requestson Mar 2, 2022
  3. benjamingr commented on Mar 2, 2022

    @benjamingr
    Member

    @jimmywarting the primary issue with something like this is that Node programs often serve multiple users (e.g. http servers) whereas web APIs are built for single-tenancy.

    The web API doesn't currently allow new CookieStore() to set up an empty store and Node can't expose an equivalent of document.cookie (nor do any of the current APIs even support cookies for the abovementioned reason).

    There definitely is the case for http clients in Node finding this useful though given the web API doesn't expose CookieStore the way it does EventTarget not sure if that's even reasonably explorable?

  4. jimmywarting commented on Mar 2, 2022

    @jimmywarting
    Author

    To be honest i don't even know if it would fit in nodejs also as you mention "it serve multiple users" you would kind of have to construct a new CookieStore for each and every user then. but i created this issue just to discuss/explore if it is reasonably

    But for things that don't work with multiple users, like a Slack, Twitter or Github client you might just only need one cookie store to communicate with one api.

    it's true that CookieStore ins't constructible, but would mean that we would have to be restricted to the same rule as the browser.

    given the web API doesn't expose CookieStore

    what do you mean? CookieStore is exposed globally (but just in secure contexts)

    Node can't expose an equivalent of document.cookie

    CookieStore dosen't have to be based on document.cookie. in some issue i read that they wish to deprecate the old document.cookie in like 5y time or something (wishful thinking). don't belive CookieStore is even based on document.cookie at all, it's just a rewrite.

  5. targos commented on Mar 2, 2022

    @targos
    Member

    To be honest i don't even know if it would fit in nodejs also as you mention "it serve multiple users" you would kind of have to construct a new CookieStore for each and every user then. but i created this issue just to discuss/explore if it is reasonably

    I personally think it makes sense. Most of my apps do not make HTTP requests on behalf of the user, even in the context of responding to them. Usually they talk to internal web services and use the same credentials regardless of the user that triggered the request.

  6. jimmywarting commented on Mar 2, 2022

    @jimmywarting
    Author

    it would have been nice if you didn't need a cookie jar plugin or something like fetch-cookie to intercept all redirects and having to reimplement all redirect logic yourself and changing redirect to manual. I agree with everything in whatwg/fetch#1384 (comment) so i do think a CookieStore have some huge value also. we would just have to make some node changes to make a CookieStore fit in a nodejs context if that is necessary. like making it possible to read each and every cookie that also has httpOnly flag

    maybe CookieStore dose not have to be constructable in the same way... maybe we could create some util that give us some new instances of a CookieStore const cookieStore = require('node:cookie-store').from(something)

  7. benjamingr commented on Mar 2, 2022

    @benjamingr
    Member

    what do you mean? CookieStore is exposed globally (but just in secure contexts)

    Thanks, I tested in example.com -_-

    I think experimentation is worth exploring then and support in undici

  8. github-actions commented on Aug 30, 2022

    @github-actions
    Contributor

    There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment.

    For more information on how the project manages feature requests, please consult the feature request management document.

  9. added
    stale
    on Aug 30, 2022
  10. benjamingr commented on Aug 30, 2022

    @benjamingr
    Member

    Please keep open

  11. removed
    stale
    on Aug 31, 2022
  12. B1773rm4n commented on Nov 1, 2022

    @B1773rm4n

    What is the status?

  13. github-actions commented on May 1, 2023

    @github-actions
    Contributor

    There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment.

    For more information on how the project manages feature requests, please consult the feature request management document.

  14. added
    stale
    on May 1, 2023
  15. added
    never-stale
    and removed
    stale
    on May 1, 2023
  16. carlosfdiazsanchez commented on Dec 27, 2024

    @carlosfdiazsanchez

    Keep open

  17. Renegade334 commented on Feb 25, 2026

    @Renegade334
    Member

    Multiple discussions over the years, including a draft implementation, appear to have concluded that this is not feasible for a Node.js environment (nodejs/undici#4525 et al.) I suggest this is closed.

  18. removed
    never-stale
    on Feb 25, 2026
  19. DenyVeyten commented on Feb 26, 2026

    @DenyVeyten

    The use case of using Node.js to run integration tests for a cookie-based API brought me here. If it's not feasible for a Node.js environment, which one is feasible then?

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

    feature request

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions