I've been trying to achieve the goal of having a unique (not shared) cookie jar per WebView in macOS (cookies management works different for iOS).
After reading a lot of StackOverflow questions and digging through the docs, I found the closest solution to my problem in these articles:
I have set up an example app using them: https://github.com/jjconti/swift-webview-isolated
The basic idea is to implement the necessary methods from the WebResourceLoadDelegate and WebPolicyDelegate protocols and use BSHTTPCookieStorage to store and retrieve cookies. Additionally, my example app allows saving the cookieStorage object so it can be reloaded in future executions.
Unfortunately, the app doesn't work correctly in every website (the author of the articles was targeting one particular web site). For example Gmail and NewRelic, you're immediately logged out after login (or after doing some actions). That makes me suspect a bug in the cookie storage implementation which I haven't been able to find yet.
Could someone tell me if there's something I'm missing?
handleWebscriptCookies
. Tried calling it once all the frames have finished loading instead of only before the NavigationAction – Insipience