ASIHTTPRequest用户登陆:重复用户登陆问题解决
2014-07-04 11:18
387 查看
使用ASIHTTPRequest来实现用户登录,但是无论如何登陆的用户总是同一个
- (IBAction)signin:(id)sender
{……..
ASIFormDataRequest *request = [ASIFormDataRequestrequestWithURL:loginUrl];
[request setDelegate:self];
[request setRequestMethod:@"POST"];
[request setPostValue:username.text forKey:@"username"];
[request setPostValue:password.text forKey:@"password"];
[request startAsynchronous];
[request setDidFailSelector:@selector(requestLoginFailed:)];
[request setDidFinishSelector:@selector(requestLoginFinished:)];
}
实现登陆的Delegate
- (void)requestLoginFinished:(ASIHTTPRequest *)request
{
NSDictionary *loginResponse = [[request responseString] objectFromJSONString];
NSLog(@"login info->%@",loginResponse);
}
但是NSLog的结果总是同一用户,解决方式是,清除Cookie,ASIHTTPRequest登陆的模式和浏览器是相似的,会保存Cookie。所以需要在每次登陆前清理。但是在SignOut时清理是不行的。
作者:Buro#79xxd 出处:http://www.cnblogs.com/buro79xxd/ 文章版权归本人所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
- (IBAction)signin:(id)sender
{……..
ASIFormDataRequest *request = [ASIFormDataRequestrequestWithURL:loginUrl];
[request setDelegate:self];
[request setRequestMethod:@"POST"];
[request setPostValue:username.text forKey:@"username"];
[request setPostValue:password.text forKey:@"password"];
[request startAsynchronous];
[request setDidFailSelector:@selector(requestLoginFailed:)];
[request setDidFinishSelector:@selector(requestLoginFinished:)];
}
实现登陆的Delegate
- (void)requestLoginFinished:(ASIHTTPRequest *)request
{
NSDictionary *loginResponse = [[request responseString] objectFromJSONString];
NSLog(@"login info->%@",loginResponse);
}
但是NSLog的结果总是同一用户,解决方式是,清除Cookie,ASIHTTPRequest登陆的模式和浏览器是相似的,会保存Cookie。所以需要在每次登陆前清理。但是在SignOut时清理是不行的。
[ASIHTTPRequestsetSessionCookies:nil];
作者:Buro#79xxd 出处:http://www.cnblogs.com/buro79xxd/ 文章版权归本人所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
相关文章推荐
- ASIHTTPRequest用户登陆:重复用户登陆问题解决
- ASIHTTPRequest用户登陆:重复用户登陆问题解决
- ASIHTTPRequest用户登陆:重复用户登陆问题解决
- .net解决了防止用户重复登陆,session超时等问题
- (转贴)一套.net窗体身份验证方案(解决了防止用户重复登陆,session超时等问题)
- 升级到iOS5后ASIHttpRequest库问题及解决方法
- 一套.net窗体身份验证方案(解决了防止用户重复登陆,session超时等问题)
- 一套.net窗体身份验证方案(解决了防止用户重复登陆,session超时等问题)
- 升级到iOS5后ASIHttpRequest库问题及解决方法
- 一套.net窗体身份验证方案(解决了防止用户重复登陆,session超时等问题)
- ASIHTTPRequest使用过程中遇到的问题及解决办法
- 一套.net窗体身份验证方案(解决了防止用户重复登陆,session超时等问题)
- 一套.net窗体身份验证方案(解决了防止用户重复登陆,session超时等问题)
- 一套.net窗体身份验证方案(解决了防止用户重复登陆,session超时等问题)
- 蛙蛙推荐:一套.net窗体身份验证方案(解决了防止用户重复登陆,session超时等问题)
- 一套.net窗体身份验证方案(解决了防止用户重复登陆,session超时等问题)
- 完美解决由NSURLConnection或者ASIHttpRequest返回的中文乱码问题。
- 蛙蛙推荐:一套.net窗体身份验证方案(解决了防止用户重复登陆,session超时等问题)
- 蛙蛙推荐:一套.net窗体身份验证方案(解决了防止用户重复登陆,session超时等问题)