What about have a topic where people can easily see how to manage cookies in a webview using the new language Swift? If you check in internet you won\'t find anything intere
Logout for api VKontakte, swift 3+
let dataStore = WKWebsiteDataStore.default()
dataStore.fetchDataRecords(ofTypes: WKWebsiteDataStore.allWebsiteDataTypes()) { (records) in
for record in records {
if record.displayName.contains("facebook") {
dataStore.removeData(ofTypes: WKWebsiteDataStore.allWebsiteDataTypes(), for: [record], completionHandler: {
print("Deleted: " + record.displayName);
})
}
}
}
If you are working on swift 4 then this code will disable cookies and also remove the URL cache.
let cookieJar : HTTPCookieStorage = HTTPCookieStorage.shared
for cookie in cookieJar.cookies! as [HTTPCookie]{
NSLog("cookie.domain = %@", cookie.domain)
cookieJar.deleteCookie(cookie)
}
URLCache.shared.removeAllCachedResponses()
URLCache.shared.diskCapacity = 0
URLCache.shared.memoryCapacity = 0