Reputation: 229
In my app users login through a SafariWebViewController and I am trying to implement a logout button for my app. When the button is pressed the following code is called.
NSHTTPCookieStorage *storage = [NSHTTPCookieStorage
sharedHTTPCookieStorage];
for (NSHTTPCookie *cookie in [storage cookies]) {
[storage deleteCookie:cookie];
}
[[NSUserDefaults standardUserDefaults] synchronize];
The code does not properly clear the cookies and when the user tries to login the SafariWebViewController remembers their last login. I am not sure what I am doing wrong that the cookies are not clearing. Any help would be appreciated.
Upvotes: 0
Views: 295
Reputation: 9923
NSHTTPCookieStorage
only affects UIWebView
and your own app's requests, it doesn't have any effect on WKWebView
or SFSafariViewController
, they use their own cookie handler.
SFSafariViewController
also shares cookies with the Safari app; my guess is only the user can clear the cache themselves (for obvious security/privacy reasons).
Use UIWebView
or WKWebView
if you want to control the cache.
Upvotes: 1