ciochPep ciochPep - 1 year ago 117
Javascript Question

Accessing localStorage from a webWorker

Can a WebWorker access the localStorage?

If not why not? Is it problematic from a security stand point?

Answer Source

No, localStorage and sessionStorage are both undefined in a webworker process.

You would have to call postMessage() back to the Worker's originating code, and have that code store the data in localStorage.

Interestingly, a webworker can use an AJAX call to send/retrieve info to/from a server, so that may open possibilities, depending on what you're trying to do.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download