Logging in to website with saved username and password

Posted by DGund on Stack Overflow See other posts from Stack Overflow or by DGund
Published on 2012-12-13T22:12:41Z Indexed on 2012/12/15 23:04 UTC
Read the original article Hit count: 183

Filed under:
|

One of the functions of an app I am making involves logging the user into our Campus Portal website. For ease of use, the user may enter a username and password into the app once, and it will be saved for all future log-ins. When the user clicks a button, the information will automatically be sent to log in, and the website will be displayed in a UIWebView.

Let us say that the username and password are each stored in an NSString. How can I use this data to log in to this website programmatically and display the page it in a UIWebView?

I know little about posting and forms, so any help is appreciated.

Would something like this Stackoverflow answer help?

Here's the shell of my code for this

- (IBAction)btnGo:(id)sender {
    username = usernameField.text;
    password = passwordField.text;
    if (saveSwitch.isOn) {
        //Save data if the user wants
        AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
        usernameSaved = username;
        passwordSaved = password;
        [appDelegate.listOfPortalCredentials replaceObjectAtIndex:0 withObject:usernameSaved];
        [appDelegate.listOfPortalCredentials replaceObjectAtIndex:1 withObject:passwordSaved];
    }
    //Insert username and password to web form, log in to portal
    //This is where I need help
}

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about ios