1

I have a button in my app which allows the user to delete all the cookies and cache. For some reason it doesn't delete all the cookies. For example when users are logged into facebook after a cookie delete action and a refresh, they are still logged in.

So the question is, what is wrong with this code? Or what should I do to guarantee all cookies are really deleted?

// Delete Cookies
func deleteCookies() {
    if let cookies = HTTPCookieStorage.shared.cookies {
        for cookie in cookies {
            HTTPCookieStorage.shared.deleteCookie(cookie)
        }
    }
}

// Delete Cache
func deleteCache() {
    URLCache.shared.removeAllCachedResponses()
    URLCache.shared.diskCapacity = 0
    URLCache.shared.memoryCapacity = 0
}
lh16
  • 1,223
  • 4
  • 17
  • 27
  • `WKWebView` dont really use `HTTPCookieStorage `, so you delete cookies there have no effect is normal thing, It probably have it own and sync to `HTTPCookieStorage` after a while – Tj3n Dec 11 '17 at 11:33
  • Thanks... Your comment solved it for me :-) – lh16 Dec 11 '17 at 11:41

0 Answers0