wkwebview与不能获取接口请求的cookie,在第一次请求的时候
[request setValue:[NSString stringWithFormat:@"key=keyValue" forHTTPHeaderField:@"Cookie"];
如果wkwebview里有ajax请求的话,需要在创建wkwebview的时候指定cookie
NSString* cookieStr = [NSString stringWithFormat:@"key=keyValue"];
NSString* source = [NSString stringWithFormat:@"document.cookie = '%@;path=/';", cookieStr];
WKUserScript * cookieScript = [[WKUserScript alloc] initWithSource:source injectionTime:WKUserScriptInjectionTimeAtDocumentStart forMainFrameOnly:NO];
[wkwebview.configuration.userContentController addUserScript:cookieScript];
这样在ajax请求的时候会把cookie带上