关闭UIWebView后维护会话 [英] Maintaining session in after closing UIWebView

查看:97
本文介绍了关闭UIWebView后维护会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,该应用程序的登录页面位于应用程序服务器上.因此,我打开一个UIWebView来处理登录.之后,我想切换到UIView并使用ASIHttp库进行API调用(也可以接受其他方法).问题是;在我登录服务器后保留会话对象用于身份验证之后,因此当我关闭UIWebView并切换到UIView并进行API调用时,它将失败.我相信,我需要以某种方式维护API调用中的会话对象(登录后设置).我怎样才能做到这一点?

I have an application which has a login page resides on the application server. So I open a UIWebView to handle the login. After then I want to switch to the UIView and make API calls using ASIHttp library (others may also be acceptable). The problem is; after I login server keeps session object for authentication purpose, so when I close the UIWebView and switch to a UIView and make an API call, it fails. I believe, somehow I need to maintain session object (set after login) in the API calls. How can I achieve this?

推荐答案

这是我遵循的步骤:

  • 使用NSHTTPCookieStorage类提取UIWebView中的cookie.
  • 使用ASIHTTPRequest setRequestCookies:方法将其发送回去进行后续调用
  • Extract the cookies in UIWebView using NSHTTPCookieStorage class.
  • Send it back using ASIHTTPRequest setRequestCookies: method for the subsequent calls

这篇关于关闭UIWebView后维护会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆