UIWebView is ignoring cookies?!
- by A. Miladinovic
Hello everybody,
I am creating an app for the iPhone that fetches a specific page from a website, but to be able to view this site you need to log in with a username and a password.
I've created this code:
NSString *urlAddress = @"http://www.wdg-hamburg.de";
NSURL *url = [NSURL URLWithString:urlAddress];
NSString *post = @"name=loginname&pass=pass&form_id=user_login&op=Anmelden";
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod: @"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
[vPlan loadRequest:request];
But I am not logged in at the UIWebView!
I am logging NSHTTPCookieStorage to the console and it shows me the necessary cookie, but I dont get logged in.
Does anybody knows how I can fix that?
Kind regards,
A. Miladinovic