Why can't serviceworker access cookies

2019-06-18 14:51发布

问题:

As per as i know Service Workers can not access the cookies. Because of this i am facing a lot of problems in implementing SW for my site.

I want to know what are the reasons, that Service Workers can not access the cookies.Right now I am using messaging to convey the cookie content to Service Workers. Is there any better way or hack to do it more efficiently?

回答1:

There is no reason. Some use cases have been proposed and a new API is under development. Sure your use case and insights are useful in the conversation if they are not covered yet.

You could use postMessage() to a client to request the cookies and send it to the service worker.