Re: [ServiceWorker] Add cookie accessor/setter methods? (#707)

I like @domenic's full-featured proposal, and agree that `id` should be a compound thing, but maybe `{ name, url }` is enough?

`.get(name, url = '/')` - get the cookie with name `foo`, and the domain/path from the url.

`.matchAll({ name: 'foo', url: '/bar/' })` - get the cookies that would be sent to a fetch to `/bar/`, then filter by name if provided. `url` defaults to `location.href`.

`.match({ name: 'foo', url: '/bar/' })` - as above but returns the first result.

`.getAll()` would be all cookies for the domain.

If I wanted to find all the (non-http-only) cookies that would be sent to `/hello/world/`, that's `.matchAll({ url: '/hello/world/' })`.

`.set(cookie)`

This means making "name" a property of the cookie.


---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/707#issuecomment-187732390

Received on Tuesday, 23 February 2016 15:05:46 UTC