iphone 使用 获取cookie
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]);