只需要將cookie存在cookieStorage裡即可
- (NSData *)send:(NSHTTPURLResponse**)urlResponse
{
NSError *errorState = nil;
NSData *result = [NSURLConnection sendSynchronousRequest:request returningResponse:urlResponse error:&errorState];
// process cookie
NSArray *allCookies = [NSHTTPCookie cookiesWithResponseHeaderFields:[*urlResponse allHeaderFields] forURL:[*urlResponse URL]];
if ([allCookies count]) {
[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookies:allCookies forURL:[*urlResponse URL] mainDocumentURL:nil];
}
return result;
}
沒有留言:
張貼留言