#pragma mark //获取请求连接的cookies
[manager POST:urlStr parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
if (success) {
success(responseObject);
NSDictionary *fields = [operation.response allHeaderFields]; //afnetworking写法
NSLog(@"fields = %@",[fields description]);
// NSURL *url = [NSURL URLWithString:@"http://api.skyfox.org/api-test.php"];
NSURL *url = [NSURL URLWithString:urlStr];
//获取cookie方法1
NSArray *cookies = [NSHTTPCookie cookiesWithResponseHeaderFields:fields forURL:url];
NSLog(@"11--%@",cookies);
//获取cookie方法2
//NSString *cookieString = [[HTTPResponse allHeaderFields] valueForKey:@"Set-Cookie"];
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
// NSLog(@"%@", error);
if (fail) {
fail();
}
}];
转载于:https://my.oschina.net/iceTear/blog/675712