登录/注销iPhone应用程序 [英] Login / Logout on an iPhone app

查看:121
本文介绍了登录/注销iPhone应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了解管理用户登录和注销IPhone原生应用程序。例如,每次我的应用程序运行时,用户都必须登录。应用程序提供的信息以及运行php + mysql的网站上的用户列表。
这是什么标准程序?是否有用于在远程站点上处理用户登录的库?

I would like to know about managing user's login and logout on IPhone native apps. For example, every time my app is running, the user must be logged in. The information the app serves and the list of users it's on a website running php+mysql. What's the "standard" procedure for this? Is there any library for handling user's login on a remote site?

您使用了哪些解决方案?饼干? php会话?

What solutions did you use? cookies? php sessions?

非常感谢任何有用网站的帮助或链接。

Any help or link to useful website will be much appreciated.

推荐答案

就个人而言,我让用户输入一次登录信息,将其存储在首选项文件中,然后在服务器请求用户进行身份验证时使用保存的信息 - 如果您使用NSURLConnection,则可以使用以下内容:

Personally I get the user to enter their login info once, store it in a preference file then use that saved information when ever the server requests the user to authenticate - if your using NSURLConnection then you can use something like:

-(void)connection:(NSURLConnection *)connection
didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge{

if ([challenge previousFailureCount] == 0) {
    NSURLCredential *newCredential;
    newCredential=[NSURLCredential credentialWithUser:[UserManager getUsername]
                                             password:[UserManager getPassword]
                                          persistence:NSURLCredentialPersistenceNone];
    [[challenge sender] useCredential:newCredential
           forAuthenticationChallenge:challenge];

} else {

    [[challenge sender] cancelAuthenticationChallenge:challenge];
    // inform the user that the user name and password
    // in the preferences are incorrect
}
}

其中 [UserManager getUsername] [UserManager getPassword] 是类中的类方法,它将从首选项文件加载用户名和密码

where [UserManager getUsername] and [UserManager getPassword] are class methods in a class that will load the username and password from a preference file

这篇关于登录/注销iPhone应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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