So i got the following problem:
I got a login viewcontroller and a form viewcontroller. On the login viewcontroller, i am sending a POST request to a PHP script which validates if the user has access. The script just returns an 1 or 0. So i can then choose to dismiss or maintain the viewcontroller. When the credentials are passed right, the user will see the form controller. This controller got a button to fetch a form.
The button to fetch the form, makes a POST request to another PHP script, which will return an XML document with the values of the user. I need a way to remember the username and password the user has passed through. So i can use them in another (view) controller.
Does anybody know a way to achieve this?
If you’re using NSURLConnection, and the session is cookie based, this would automatically be done. So all you’d need to write would be similar to this
And you would have to implement the NSURLConnectionDelegate methods as well
If you have some other information thats in the headers and which you need to send back with consequent requests, you can read it from the response like this
And set the header fields for the next request like this
To save information, be it username and/or password or session information you can use NSUserDefaults
Lastly, it would be advisable to build a model to map the xml API with [Eg: a User class with username and password properties].
Google for Apple’s docs on MVC.
Hope this helps!