Search code examples
iphoneauthlogicasihttprequest

Using Authlogic persistence token with ASIHTTPRequest


I am building an iPhone app where I would like authenticate with a rails server that uses Authlogic for authentication.

I am okay sending the username/password once but would like to use the persistence_token for auth following that.

I am unable to authenticate with the rails server. What special magic do I need to do to get persistence_token to work? Do I pass it in the header or set it in the cookies? Also do I need to wrap it in user_session?

I am using ASIHTTPRequest to make JSON calls.

Many thanks for the help! I am hoping anyone else who has a similar question in the future will end up saving hours once this question is correctly answered. Also, I realize my understanding of persistence_token might not be correct, in that case, please correct me.


Solution

  • Looks like persistence_token is set in the cookies as user_session=. One could set the cookie for every request, but I am just logging in with ASIHTTP once the client is started. ASIHTTP/NSURL continues to save the cookies for all the recurring calls.