KWMHttpUtil.m 904 Bytes
Newer Older
lee committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
//
//  KWMHttpUtil.m
//  iCemarose
//
//  Created by lee on 2017/5/25.
//  Copyright © 2017年 kollway. All rights reserved.
//

#import "KWMHttpUtil.h"

@implementation KWMHttpUtil

+ (NSString *)buildRequestCookieString {
    NSArray *cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies];
    NSMutableString *cookieString = [[NSMutableString alloc] init];
    for (NSHTTPCookie *cookie in cookies) {
        [cookieString appendFormat:@"%@=%@; ",cookie.name,cookie.value];
    }
    return cookieString;
}

lee committed
22 23 24 25 26 27 28 29 30 31 32
+ (void)deleteCookie:(NSString *)name {
    NSArray *cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies];
    for (int i=0; i<cookies.count; i++) {
        NSHTTPCookie *cookie = cookies[i];
        if ([cookie.name isEqualToString:name]) {
            [[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
            return;
        }
    }
}

lee committed
33
@end