Re: [ServiceWorker] Support modifying cookies on an intercepted fetch (#837)

To expand on the issue: some sites set cookies to expire after short periods for security reasons, but would like to keep a longer term cookie on the client, and then when the short term cookie expires they'd like to make a single "cookie refresh" request with the long term cookie that will provide a new short term cookie which can be added to the original request that had the expired cookies.

If cookies only get added after the SW has processed then would the following possibly work?

1. Intercept a request to /index.html 
2. Use the new (not yet implemented) `getCookies` API to inspect the cookies and decide whether they need refreshing
3. Make a request to the refresh cookies endpoint, which would use headers to set a cookie on the client
4. Let the request intercepted in 1 go to the network, as at this point the new cookies set in 3 would be added to it

On a high level it sounds like cookies get added after the request leaves the SW so modifying cookies on a request is possible by adding cookies directly to the origin before the request leaves the SW. Let me know if that doesn't sound true though.

---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/837#issuecomment-187370650

Received on Monday, 22 February 2016 20:31:53 UTC