ASIHTTPRequest用户登陆:重复用户登陆问题解决
<div id="cnblogs_post_body">使用ASIHTTPRequest来实现用户登录,但是无论如何登陆的用户总是同一个- (IBAction)signin:(id)sender
{&hellip;&hellip;..
ASIFormDataRequest *request = [ASIFormDataRequestrequestWithURL:loginUrl];
setDelegate:self];
setRequestMethod:@"POST"];
setPostValue:username.text forKey:@"username"];
setPostValue:password.text forKey:@"password"];
startAsynchronous];
setDidFailSelector:@selector(requestLoginFailed:)];
setDidFinishSelector:@selector(requestLoginFinished:)];
}
实现登陆的Delegate
- (void)requestLoginFinished:(ASIHTTPRequest *)request
{
NSDictionary *loginResponse = [responseString] objectFromJSONString];
NSLog(@"login info->%@",loginResponse);
}
但是NSLog的结果总是同一用户,解决方式是,清除Cookie,ASIHTTPRequest登陆的模式和浏览器是相似的,会保存Cookie。所以需要在每次登陆前清理。但是在SignOut时清理是不行的。
[ASIHTTPRequestsetSessionCookies:nil];
页:
[1]