Skip to content

Instantly share code, notes, and snippets.

@kosso
Created October 12, 2012 07:24
Show Gist options
  • Save kosso/3877780 to your computer and use it in GitHub Desktop.
Save kosso/3877780 to your computer and use it in GitHub Desktop.
Making sure people log out of web-authed apps.
- (void)clearWebViewCookies:(NSMutableArray*)cleardomain
{
NSLog(@"[INFO] called webView clearWebViewCache to clear : %@", [cleardomain objectAtIndex:0]);
for(NSHTTPCookie *cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]) {
//NSLog(@"[INFO] cookie for : %@",[cookie domain]);
if([[cookie domain] isEqualToString:[cleardomain objectAtIndex:0]]) {
//NSLog(@"[INFO] deleting cookie for : %@",[cookie domain]);
[[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
}
}
}
- (void)emptyCache
{
[[NSURLCache sharedURLCache] removeAllCachedResponses];
NSLog(@"[INFO] nuking the webView cache");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment