title: What's the best way to keep ios app signed in?
body: <p>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.</p>
  
  <p>after digging in Apple documents for several hours, I can point out two methods to implement the idea:
  &lt;1> use http basic/digest authentication. 
  Once user is authenticated, i save username and password in keychain. Whenever the server requires authentication, by implementing <strong>connection:didReceiveAuthenticationChallenge:</strong> function, app can load username and password, and construct legal <strong><a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/Articles/AuthenticationChallenges.html#//apple_ref/doc/uid/TP40009507-SW1" rel="nofollow">NSURLCredential</a></strong>. Certainly it will work, but every request must authenticate one time and transfer user secret frequently.</p>
  
  <p>&lt;2> use http cookie
  Once user is authenticated, the server response with a unique token in cookie. Depend on the feature <strong><a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/Concepts/URLOverview.html" rel="nofollow">The URL loading system automatically sends any stored cookies appropriate for an NSURLRequest</a></strong>. I'm not sure whether the cookie will be lost when user kill the app.</p>
  
  <p>Do you think the two methods is ok? which one is better? Is there any other methods to do the same thing?</p>
  
  <p>I notice many clients(twitter/facebook/...) keep user signed in, what method they use?
  Thanks;</p>
  
  <p>BTW, I have saved username and password in keychain, but to keep signed in, I think there is more work to do.</p>