Iphone UIWebView正在忽略Cookie?

Iphone UIWebView正在忽略Cookie?,iphone,objective-c,cocoa-touch,Iphone,Objective C,Cocoa Touch,我正在为iPhone创建一个应用程序,可以从网站获取特定页面,但要查看此网站,您需要使用用户名和密码登录 我创建了以下代码: NSString *urlAddress = @"http://www.wdg-hamburg.de"; NSURL *url = [NSURL URLWithString:urlAddress]; NSString *post = @"name=loginname&pass=pass&form_id=user_login&op=Anmelden

我正在为iPhone创建一个应用程序,可以从网站获取特定页面,但要查看此网站,您需要使用用户名和密码登录

我创建了以下代码:

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];
但是我没有登录UIWebView

我正在将
NSHTTPCookieStorage
登录到控制台,它会向我显示必要的cookie,但我没有登录

有人知道我该怎么解决吗

亲切问候,


A.米拉迪诺维奇

您是否尝试过在标题中设置cookie

NSArray* cookies = [NSArray arrayWithObjects: cookie, nil];
NSDictionary * headers = [NSHTTPCookie requestHeaderFieldsWithCookies:cookies];
[request setAllHTTPHeaderFields:headers];

我也有类似的问题。你找到解决办法了吗?