Making WKWebView not share cookies with Safari in OS X

和自甴很熟 提交于 2019-12-06 02:56:15

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!