Alamofire清除所有饼干 [英] Alamofire clear all cookies
本文介绍了Alamofire清除所有饼干的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要用户能够注销。当他们现在登录时,cookie会自动保存,工作正常。但我想清除所有cookie。
I need the user to be able to log out. When they log in now, a cookie gets saved automatically, that works fine. But I want to clear all cookies.
NSURLCache.sharedURLCache().removeAllCachedResponses()
这不起作用
推荐答案
你可以删除专门为这样的URL存储的所有cookie(Swift 3):
You can remove all the cookies specifically stored for an URL like this (Swift 3):
let cstorage = HTTPCookieStorage.shared
if let cookies = cstorage.cookies(for: url) {
for cookie in cookies {
cstorage.deleteCookie(cookie)
}
}
这篇关于Alamofire清除所有饼干的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文