I'm working on a ios app need to communicate with server. When user first time launch the app, he's prompted to input his username and password. Once he's authenticated, i want to keep him signed in until he signed out explicitly.
after digging in Apple documents for several hours, I can point out two methods to implement the idea: <1> use http basic/digest authentication. Once user is authenticated, i save username and password in keychain. Whenever the server requires authentication, by implementing connection:didReceiveAuthenticationChallenge: function, app can load username and password, and construct legal NSURLCredential. Certainly it will work, but every request must authenticate one time and transfer user secret frequently.
<2> use http cookie Once user is authenticated, the server response with a unique token in cookie. Depend on the feature The URL loading system automatically sends any stored cookies appropriate for an NSURLRequest. I'm not sure whether the cookie will be lost when user kill the app.
Do you think the two methods is ok? which one is better? Is there any other methods to do the same thing?
I notice many clients(twitter/facebook/...) keep user signed in, what method they use? Thanks;
BTW, I have saved username and password in keychain, but to keep signed in, I think there is more work to do.