Uiwebview session issue

NSURL *url = [NSURL URLWithString:@"http://ip/login"];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL: url];
NSString *body = [NSString stringWithFormat: @"name=%@&pass=%@", @"phpxiaoxin", @"86f7e437faa5a7fce15d1ddcb9eaeaea377667b8"];
[request setHTTPBody: [body dataUsingEncoding: NSUTF8StringEncoding]];
[request setHTTPMethod: @"POST"];
//Load the request in the UIWebView.
[webView loadRequest:request];

url = [NSURL URLWithString:@"http://ip/hotel/hotelReservationList.action"];

request = [[NSMutableURLRequest alloc]initWithURL: url];
[webView loadRequest:request];

Hi everyone, I have a problem with uiwebview session reason; now first I want to use the postmethod method to log in, then I need to control the redirection to the "hotelreservation.action" action, but the second request does not extend the first session, so the result is a redirection of the web system to the login page, what should I do with uiwebview I know that I can redirect on the Internet, but I need to control web browsing. so can anyone help me? many thanks

+3
source share
1 answer

You must execute the second request in the method UIWebViewDelegate webViewDidFinishLoad:.

+3

Source: https://habr.com/ru/post/1734680/


All Articles