iOS AFNetworking中cookie重定向

// 1. 取出需要同步的url (登录请求中返回的重定向地址)
BESTHttpItem *httpItem = [BESTHttpHelper sharedHelper].curHttpItem;
NSString  *url = [NSString stringWithFormat:@"%@/#/login", httpItem.frontend_addr];

// 2. 取出当前的headerFields
NSDictionary *headerFields = [NSHTTPCookie requestHeaderFieldsWithCookies:self.cookies];

// 3. 替换cookie地址
[NSHTTPCookie cookiesWithResponseHeaderFields:headerFields forURL:[NSURL URLWithString:url]];

posted @ 2016-09-27 11:15  小C酱  阅读(1046)  评论(0编辑  收藏  举报