int i;

NSDictionary *dic = [NSDictionary dictionaryWithObject:@"name=value; path=/; domain=.test.com;, name2=value2; path=/;" forKey:@"Set-Cookie"];

NSArray *cookies = [NSHTTPCookie cookiesWithResponseHeaderFields:dic forURL:[NSURL URLWithString:@"http://www.foo.com/"]];

 

for (i = 0; i < [cookies count]; i++)

{

NSHTTPCookie *cookie = [cookies objectAtIndex:i];

NSLog(@"%@ for %@",[cookie name], [cookie domain]);

}

for (NSHTTPCookie *cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies])

{

    NSLog(@"name: '%@'\n",   [cookie name]);

    NSLog(@"value: '%@'\n",  [cookie value]);

    NSLog(@"domain: '%@'\n", [cookie domain]);

相关文章:

  • 2021-12-28
  • 2022-12-23
  • 2022-01-24
  • 2022-12-23
  • 2021-10-05
  • 2021-12-20
  • 2022-02-09
猜你喜欢
  • 2021-04-24
  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
  • 2021-08-13
  • 2022-01-10
相关资源
相似解决方案