NSURLRequest*request =[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com/"]];
NSURLConnection*connection =[NSURLConnection connectionWithRequest:request delegate:self];
-(void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response
{
   
NSHTTPURLResponse*HTTPResponse=(NSHTTPURLResponse*)response;
   
NSDictionary*fields =[HTTPResponse allHeaderFields];
   
NSString*cookie =[fields valueForKey:"Set-Cookie"];// It is your cookie
}
保存好Cookie,当另一个request要用到这个cookies时,用如下方法加入:
NSMutableURLRequest*request =[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com/"]];
[request addValue:cookie forHTTPHeaderField:"Cookie"];

相关文章:

  • 2021-10-25
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2022-12-23
  • 2022-12-23
  • 2021-10-06
  • 2022-12-23
猜你喜欢
  • 2021-12-12
  • 2021-12-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案