Can a WebWorker access the localStorage?
If not why not? Is it problematic from a security stand point?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.