如何在iPhone上创建和维护身份验证会话? [英] How can I create and maintain authentication sessions on an iPhone?
本文介绍了如何在iPhone上创建和维护身份验证会话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要创建一个具有帐户系统的iphone应用程序. (登录/注销).
i am about to create an iphone application that will have a account system . ( login/logout ) .
也将具有服务器端.那么如何进行会话管理.当您的客户使用iphone时
that will have a server side also. so how to do session management. while your client is iphone
我该怎么做??
推荐答案
我使用 ASIHTTPRequest 库与我的Web服务进行通信.
I use the ASIHTTPRequest library to communicate with my webservice.
它具有处理cookie的内置功能,因此我只需使用POST请求登录,就可以像设置普通浏览器一样设置cookie.
It has built-in capability to handle cookies, so I simply login with a POST request and the cookie is set like a normal browser.
当网络连接断开时,您仍然可以检查有效的cookie:
When your network connection is down, you can still check for a valid cookie:
- (BOOL) hasSignInCookie
{
NSArray *cookieJar = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies];
for( NSHTTPCookie *cookie in cookieJar)
{
if( [[cookie name] compare: @"JourneyTagID"] == NSOrderedSame)
{
return YES;
}
}
return NO;
}
这篇关于如何在iPhone上创建和维护身份验证会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文