开发者

How do I store credentials so I do not need to authenticate to a server each time?

I just finished implementing my first iPhone application , everything went well, now I need to supply a sort of security to my application and I don't know what is the best way to do that ?

Currently it works like this : the user enters his user name and password , the server verifies that this is the correct information , when I made another request to the server it asks for a user name and password so it returns to the method named didReceiveAuthenticationChallenge. I provide the user name and password again , the server verifies that, and sends the request again.

My questions are : Is this a correct behavior? is there any kind of session for iphone? And how开发者_StackOverflow社区 can I use cookies to save user name and password ?

Also I stored newCredential = [NSURLCredential credentialWithUser:username password:password persistence:NSURLCredentialPersistenceForSession];

But it not stored for session. Is there problem in my code on the iPhone or the PHP script that we are calling?


Consider using the Keychain API to store and retrieve credentials securely. This will even preserve credentials between application restarts, if this is desirable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜