iOS 设置Cookie HttpOnly

NSMutableDictionary *scookieProperties = [NSMutableDictionary dictionary];
        [scookieProperties setObject:@"_s" forKey:NSHTTPCookieName];
        [scookieProperties setObject:@"true" forKey:@"HttpOnly"];
        [scookieProperties setObjectSafe:cookieOne forKey:NSHTTPCookieValue];
        [scookieProperties setObject:@".baidu.com"forKey:NSHTTPCookieDomain];
        [scookieProperties setObject:@"/" forKey:NSHTTPCookiePath];
        [scookieProperties setObject:@"0" forKey:NSHTTPCookieVersion];
        
        NSHTTPCookie*scookie = [NSHTTPCookie cookieWithProperties:scookieProperties];
        [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:scookie];
        
        NSMutableDictionary *tCookieProperties = [NSMutableDictionary dictionary];
        [tCookieProperties setObjectSafe:@"cookieTwoName" forKey:NSHTTPCookieName];
        [tCookieProperties setObjectSafe:cookieTwo forKey:NSHTTPCookieValue];
        [tfCookieProperties setObjectSafe:@".baidu.com"forKey:NSHTTPCookieDomain];
        [tCookieProperties setObjectSafe:@"/" forKey:NSHTTPCookiePath];
        [tCookieProperties setObjectSafe:@"0" forKey:NSHTTPCookieVersion];
        
        NSHTTPCookie *csrfHttpCookie = [NSHTTPCookie cookieWithProperties:tCookieProperties];
        [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:csrfHttpCookie];
iOS 设置Cookie HttpOnly_第1张图片
1.jpg

你可能感兴趣的:(iOS 设置Cookie HttpOnly)