问题
How do I make WKWebView not share cookies with Safari in OSX?
I have a very simple app that I made as an experiment that displays a WKWebView and as far as I can see, it's picking up cookies from Safari, because in my custom app, I'm logged in in the same websites as Safari.
I am currently creating the WKWebView instance like this:
override func loadView() {
self.webView = WKWebView()
self.view = self.webView!
}
in an NSViewController I created. I also tried this:
override func loadView() {
var processPool = WKProcessPool()
var config = WKWebViewConfiguration()
config.processPool = processPool
self.webView = WKWebView(frame: CGRect(x: 0, y: 0, width: 100, height: 100), configuration: config)
self.view = self.webView!
}
but it made no difference to cookie storage. I don't have an issue creating my own cookie storage as long as it's not using hacks, as previous hacks for WebView did not work. I just need cookies to not be shared between my app and Safari.
来源:https://stackoverflow.com/questions/28741177/making-wkwebview-not-share-cookies-with-safari-in-os-x