zoukankan      html  css  js  c++  java
  • ASIHTTPRequest用户登陆:重复用户登陆问题解决

    使用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时清理是不行的。

    [ASIHTTPRequestsetSessionCookies:nil];
    作者:Buro#79xxd 出处:http://www.cnblogs.com/buro79xxd/ 文章版权归本人所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    leetcode 33. Search in Rotated Sorted Array
    leetcode 28. Implement strStr()
    Scala函数
    布隆过滤器相关知识
    Storm 流式计算框架
    java高并发核心类 AQS(Abstract Queued Synchronizer)抽象队列同步器
    操作系统类型&操作系统结构&现代操作系统基本特征
    Kafka笔记
    Redis shell
    Lucene笔记
  • 原文地址:https://www.cnblogs.com/buro79xxd/p/2640130.html
Copyright © 2011-2022 走看看