[whatwg] HTML Cookie API

On Wed, Feb 24, 2010 at 4:30 PM, Garrett Smith <dhtmlkitchen at gmail.com> wrote:
> On Wed, Feb 24, 2010 at 4:17 PM, Adam Barth <w3c at adambarth.com> wrote:
>> On Wed, Feb 24, 2010 at 4:03 PM, Garrett Smith <dhtmlkitchen at gmail.com> wrote:
>>> Instead of "array like", I would like to rather have a NamedCookieMap,
>>> which is sort of like a NamedNodeMap that the cookies can be retrieved
>>> by an item or namedItem.
>>
>> That API design assumes that there's only one cookie with a given name
>> in each cookie-string. ?Unfortunately, that is not a valid assumption.
>
> That is only true in that that example assumes that each cookie is
> named. It would be entirely possible for the value to be instead a
> collection, as in:
>
> var x = document.forms[0].elements["radioName"]
>
> - and the result is that x could be either an element or a collection
> of elements.

That seems more complex than just providing a list of cookies.

>>> Where is the argument for making the API async?
>>
>> Please see the discussion earlier in this thread.
>>
> Can you be more specific? I see:
>
> | I really think the API should be asynchronous, as to avoid the mess
> | that .localStorage currently is.
>
> But I don't know if that's what you meant by "please see earlier".

I mean looking at
http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2010-February/thread.html
and reading the thread rooted at
http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2010-February/025300.html.
 In particular,

http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2010-February/025325.html
http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2010-February/025326.html
http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2010-February/025327.html
http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2010-February/025331.html

Those messages also refer to thousands of messages about localStorage.
 All the synchrony issues with localStorage recur here.

>>> Cookies have been synchronous for longer than I have been writing
>>> javascript and to my knowledge, nobody has ever complained of that
>>> being a problem.
>>
>> In fact, I've heard a great many complaints about this recently
>> (particularly from Darin Fisher), which is part of what prompted me to
>> make this proposal.
>
> Is there a link to that? I missed it.

http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2010-February/025326.html

... plus personal communication.

>>> Asynchronous cookies that would mean that cookie setting tests would be harder.
>>
>> No one is suggesting removing the current document.cookie API.
>
> Nobody is suggesting you change your tires. Why bring it up?

This API does not make it any harder to test whether setting a cookie
works because you can still use whatever test you like.  If we want to
solve the problem of making cookie feature testing easier, we can do
that.

Adam

Received on Wednesday, 24 February 2010 16:52:59 UTC