tags:

views:

197

answers:

1

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 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?

+1  A: 

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

Alex Reynolds
Using: NSURLCredentialPersistencePermanentCredential will be stored in the user’s keychain and shared with other applications.
zaph
I also tried NSURLCredentialPersistencePermanent but not stored if I call the next webURL using the initwithrequestmethod or POST method .when i tried on the browser firefox it doeesn`t ask for credentials again but on mac safari it ask .Is the problem with the webscript .
crystal