W3C home > Mailing lists > Public > whatwg@whatwg.org > March 2009

[whatwg] Accessing cookies from workers

From: Jonas Sicking <jonas@sicking.cc>
Date: Thu, 5 Mar 2009 17:42:47 -0800
Message-ID: <63df84f0903051742t3821f69egcb3b8381a8a89486@mail.gmail.com>
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") {
else {
  log("cookies certainly aren't 'hello', they are: " + docCookies);

could result in "cookies certainly aren't 'hello', they are: hello"
being printed.

/ Jonas
Received on Thursday, 5 March 2009 17:42:47 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:10 UTC