How can I erase all cookies from the NSHTTPCookieStorage.sharedHTTPCookieStorage? The only methods I am aware of delete a single specified cookie, however, the cookies are handled behind the scenes by NSURLSession. (Programming in Swift)
This achieves the same result as the other answers but with one line of code:
HTTPCookieStorage.shared.cookies?.forEach(HTTPCookieStorage.shared.deleteCookie)
let cookieStore = NSHTTPCookieStorage.sharedHTTPCookieStorage()
for cookie in cookieStore.cookies ?? [] {
cookieStore.deleteCookie(cookie)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With