iOS 清除某个域名下的cookie

2017-05-16  本文已影响89人  杨柳小易

清除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];
}

上一篇 下一篇

猜你喜欢

热点阅读