I use the new WKHTTPCookieStore class to insert and remove cookies from WKWebViews in the application.
All WKWebViews have a common WKWebViewConfiguration so that they can share a common cookie store.
Injection cookies work fine with the add() method, and each of the web views can see the new cookies and send them with their requests. Deleting cookies seems to be a problem - web views still see the allegedly deleted cookie and continue to send it with every request:
let cookieStore = self.webkitConfiguration.websiteDataStore.httpCookieStore cookieStore.getAllCookies { (cookies) in for cookie:HTTPCookie in cookies { if cookie.name == "CookieIWantToDelete" { cookieStore.delete(cookie, completionHandler: { self.webView.reload() //Deleted cookie is still sent with this request }) } } }
I can get around this by destroying all the cookies in the WKWebsiteDataStore , but it seems to be a bit overkill.
Any ideas?
source share