UIWebView is ignoring cookies?!
Posted
by A. Miladinovic
on Stack Overflow
See other posts from Stack Overflow
or by A. Miladinovic
Published on 2010-04-28T20:00:38Z
Indexed on
2010/04/28
20:07 UTC
Read the original article
Hit count: 817
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
© Stack Overflow or respective owner