[whatwg] Accessing cookies from workers
Jonas Sicking
jonas at sicking.cc
Thu Mar 5 17:42:47 PST 2009
On Thu, Mar 5, 2009 at 5:23 PM, Michael Nordman <michaeln at google.com> wrote:
>> Allowing cookie to be set would unfortunately create a synchronous
>> communication channel between the worker and the main window. This is
>> something that we need to avoid to prevent users from having to deal
>> with locking and other thread related issues.
>
> Hmmm... the cookie setting API could be async in workers.
Or you could just use postMessage() and ask the main thread to do it?
What is the use case for reading/writing cookies though? Could use use
localStorage instead (once we figure out a different API for it that
doesn't have the shared-state problem that the current API has)
Even just synchronous read access has race-condition problems. For
example the following script:
if (docCookies == "hello") {
doStuff();
}
else {
log("cookies certainly aren't 'hello', they are: " + docCookies);
}
could result in "cookies certainly aren't 'hello', they are: hello"
being printed.
/ Jonas
More information about the whatwg
mailing list