Search code examples
javascriptweb-worker

Can I access document cookie on web worker


Though document is not accessible from web worker can i access some how the cookie? unless i send a postMessage to main thread to give me cookie and it will send it via another postMessage


Solution

  • No, you can access neither cookies nor localStorage ("local cookies").

    Apart from using postMessage, you could also send a AJAX request to server to get/set a cookie. This is in no way more optimal of course - it will take way longer.