Skip to content

Instantly share code, notes, and snippets.

@croath
Last active December 13, 2015 22:29
Show Gist options
  • Save croath/4984421 to your computer and use it in GitHub Desktop.
Save croath/4984421 to your computer and use it in GitHub Desktop.
clear cookies in iOS
- (void)clearCookies{
NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (NSHTTPCookie *each in cookieStorage.cookies) {
if ([[[each properties] objectForKey:NSHTTPCookieDomain] isEqualToString:@".douban.com"] &&
[[[each properties] objectForKey:NSHTTPCookieName] isEqualToString:@"bid"]) {
[cookieStorage deleteCookie:each];
NSDictionary* dic = [each properties];
[dic setValue:@"" forKey:NSHTTPCookieValue];
NSHTTPCookie* cookie = [NSHTTPCookie cookieWithProperties:dic];
[cookieStorage setCookie:cookie];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment