Since this question has not received an answer in a year, I am sending my imperfect, but working solution:
You can have access to the NSHTTPURLResponse object in the method - webView:decidePolicyForNavigationResponse:decisionHandler: defined in WKNavigationDelegate . You can subsequently extract the cookies manually from the HTTP header:
- (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler { NSHTTPURLResponse* response = navigationResponse.response; NSArray *cookies = [NSHTTPCookie cookiesWithResponseHeaderFields:[response allHeaderFields] forURL:[NSURL URLWithString:@""]]; for (NSHTTPCookie *cookie in cookies) {
Please post your decision if you have the best.
Siyu song
source share