iOS 清除某个域名下的cookie

清除cookie

+ (void)clearCookie:(NSString*)domain
{
    NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
    for (NSHTTPCookie *cookie in [storage cookies]) {
        if ([cookie.domain rangeOfString:domain].location != NSNotFound) {
            [storage deleteCookie:cookie];
        }
    }
    [[NSUserDefaults standardUserDefaults] synchronize];
}

你可能感兴趣的:(iOS 清除某个域名下的cookie)