[whatwg/fetch] [Feature request] Add a `CookieStore` option to `Request` (Issue #1384)

I was looking into how some form of how a cookie jar could fit into NodeJS and Deno. 
...it totally lacks any form of cookie handling. A default cookie jar would not be so perfect for backend either.

There exist some grate libraries like [tough-cookie](https://github.com/salesforce/tough-cookie) but isn't so web-ish when it comes to something as spec'ed as the [CookieStore](https://wicg.github.io/cookie-store/#CookieStore)

I was thinking that it would be cool if CookieStore where constructible and being able to pass this to fetch/Request as an option. and so that we can agree upon a unified way of dealing with cookies jars in both Deno and NodeJS.

```js
const cookieStore = new CookieStore()
const request = new Request(url, { cookieStore })
fetch(request)
```

This would take care of setting request `cookie`s that exist in the store and parsing incoming `set-cookies` like during redirects as well.

I was maybe thinking this could be useful for the web as well where you have the desire to handle multiple sessions/accounts simultaneously and dealing with cookies yourself in different tabs. This could also be a way of telling a single page application that cookies should never store a cookie on the clients machine (whetter it be session or persistent) maybe you could store it in indexeddb? it would totally be discarded when you leave the page

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/1384
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/fetch/issues/1384@github.com>

Received on Sunday, 23 January 2022 14:54:33 UTC