0

我正在尝试从服务器获取 cookie,因此我可以使用用户名和密码以及 cookie 登录服务器。

ASIHTTPRequest我得到饼干

JSESSIONID=Pt1vcPv0TbaRsK2J6nnWuHu4.pard; Path=/parity,JSESSIONID=z9Gf40eSCVsF3xYcG-yrONsU.pardemo; Path=/parity,NSC_QBSJUFN-EFNP=ffffffff090b1dd445525d5f4f58455e445a4a4229a0;path=/

在 NSHTTPCookie 中,我得到了非常不同的结果,这就是我调用 cookie 的方式。有没有办法让我得到上面的结果?

NSMutableURLRequest *postRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://www.exapmle.com/server/api.ashx"]];

NSArray *cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies];
NSHTTPCookie *cookie =[[NSHTTPCookie alloc]init];
for (int i = 0; i < [cookies count]; i++) {

    cookie = [cookies objectAtIndex:i];

    NSLog(@"Cookie: %@, %@, %@ ,%@", [cookie domain],[cookie path],[cookie name],[cookie value]);

    }
}
4

1 回答 1

0

ASIHttp 已经很老了,即使它的开发人员建议你停止使用它,也不再使用它Link

搬到 AFNetworking一个好人的好图书馆。

于 2014-11-13T09:42:36.283 回答