Alamofire清除所有饼干

alv*_*lof 12 cookies login ios swift alamofire

我需要用户能够注销.当他们现在登录时,cookie会自动保存,工作正常.但我想清除所有的cookie.

NSURLCache.sharedURLCache().removeAllCachedResponses()
Run Code Online (Sandbox Code Playgroud)

这不起作用

aya*_*aio 27

您可以删除专门为此URL存储的所有Cookie(Swift 3):

let cstorage = HTTPCookieStorage.shared
if let cookies = cstorage.cookies(for: url) {
    for cookie in cookies {
        cstorage.deleteCookie(cookie)
    }
}
Run Code Online (Sandbox Code Playgroud)