[whatwg] HTML Cookie API

Darin Fisher darin at chromium.org
Wed Feb 24 11:21:39 PST 2010


For reference, reading document.cookie has measurable performance cost in
Chromium since the cookie jar lives in a process separate from the process
running JavaScript.  We could have minimized this cost by caching the
cookies locally, but then there are cache coherency issues.

I think the cookie APIs should have been asynchronous from the start.
 Whenever an API is backed by I/O, asynchronous should be the rule.

-Darin


On Wed, Feb 24, 2010 at 11:11 AM, Nicholas Zakas <nzakas at yahoo-inc.com>wrote:

> I like the idea of creating an easier way to deal with cookies (which is
> why I wrote the YUI Cookie utility way back when). The thing that seems to
> be missing in your proposed API is what I consider to be the most common use
> case: retrieving the value of a single cookie. There's not many times when I
> need to get every single cookie that's available on the page, but there are
> plenty of times when I want to check the value of a single cookie. Using
> your API, getting the value of a single cookie with a known name becomes:
>
>    document.getCookies(function(cookies) {
>      for (var i=0; i < cookies.length; ++i){
>          if(cookies[i].name == "my_cookie_name"){
>              doSomething(cookies[i]);
>          }
>      }
>    });
>
> That seems like a lot of work just to retrieve a single cookie value.
>
> I'm also less-than-thrilled with this being asynchronous, as I think the
> use cases for cookies are vastly differently than those for databases and
> web storage. The world is already parsing cookies synchronously right now,
> it doesn't seem like asynchronicity buys much benefit, it just introduces an
> additional level of indirection.
>
> -Nicholas
>
> ______________________________________________
> Commander Lock: "Damnit Morpheus, not everyone believes what you believe!"
> Morpheus: "My beliefs do not require them to."
>
> -----Original Message-----
> From: whatwg-bounces at lists.whatwg.org [mailto:
> whatwg-bounces at lists.whatwg.org] On Behalf Of Adam Barth
> Sent: Wednesday, February 24, 2010 8:47 AM
> To: Darin Fisher
> Cc: whatwg
> Subject: Re: [whatwg] HTML Cookie API
>
> Done.
>
> On Wed, Feb 24, 2010 at 12:29 AM, Darin Fisher <darin at chromium.org> wrote:
> > An explicit deleteCookie method might also be nice.
> > -Darin
> >
> > On Tue, Feb 23, 2010 at 8:56 PM, Adam Barth <w3c at adambarth.com> wrote:
> >>
> >> The document.cookie API is kind of terrible.  Web developers shouldn't
> >> have to parse a cookie-string or prepare a properly formated
> >> set-cookie-string.  Here's a proposal for an HTML cookie API that
> >> isn't as terrible:
> >>
> >>
> >>
> https://docs.google.com/Doc?docid=0AZpchfQ5mBrEZGQ0cDh3YzRfMTRmdHFma21kMg&hl=en
> >>
> >> I'd like to propose we include this API in a future version of HTML.
> >> As always, feedback welcome.
> >>
> >> Adam
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20100224/2168597e/attachment-0001.htm>


More information about the whatwg mailing list