ios - 如何清除 OAuthSwift 库中的 cookie(OAuth2.0)
问题描述
我在我的应用程序中使用 OAuthSwift Auth2.0 库,我们正在尝试使用以下代码在按下“注销”按钮时清除浏览器中的 cookie 详细信息,但脚本不会从内部浏览器中删除会话 cookie。我无法从内部浏览器中清除 cookie。
//Calling the URl
oauthswift.authorizeURLHandler = SafariURLHandler(viewController: self, oauthSwift: oauthswift)
SafariURLHandler(viewController: self,oauthSwift:oauthswift)
// Remove the cookies
URLCache.shared.removeAllCachedResponses()
if let cookies = HTTPCookieStorage.shared.cookies{
for cookie in cookies {
HTTPCookieStorage.shared.deleteCookie(cookie)
}
}
let storage = HTTPCookieStorage.shared
if let cookies = storage.cookies {
for cookie in cookies {
storage.deleteCookie(cookie)
}
}
let dataTypes = Set([WKWebsiteDataTypeCookies,
WKWebsiteDataTypeLocalStorage, WKWebsiteDataTypeSessionStorage,
WKWebsiteDataTypeWebSQLDatabases, WKWebsiteDataTypeIndexedDBDatabases])
WKWebsiteDataStore.default().removeData(ofTypes: dataTypes, modifiedSince: NSDate.distantPast, completionHandler: {})
navigationController?.popToRootViewController(animated: true)
}
有人可以帮忙吗?
解决方案
推荐阅读
- label - 在 gnuplot 数据系列中标记点
- postgresql - 如何防止 PostgreSQL JSON/JSONB 字段中的 SQL 注入?
- javascript - .on('change' ...) 不会触发 JS 更改的数据
- php - MVC PHP - 在控制器中找不到html提交名称
- html - 文本框比它所在的列大小大 100%
- node.js - Javascript 日期 - 删除时区信息
- php - PHP从内表显示$rows
- c# - 填充另一个属性后填充视图模型
- c - 将类型和无效操作数分配给二进制时的类型不兼容
- python - OpenCV“imshow”函数打开很多窗口而不是替换一个窗口上的框架 - Python