title: WKWebView AJAX calls losing cookies
body: <p>Our customer requested us to do a switch from WebView to WKWebView recently. Their app uses native login, which is done by a 2 POST calls to their backend, returning various authorization cookies that were later on used in every single HTTP/AJAX call throughout the whole app. </p>
  
  <p>With the WebView, it all worked like a charm without a need to implement a single line of custom code. User logged in, cookies were stored to cookie storage by default, and WebView always took them from there and used them, since the HTTPCookieStorage was shared between NSURLSession and WebView. </p>
  
  <p>It it a whole new story with WKWebView. Once we switched WebView to WKWebView, we saw that the authorization was not working. It was due to losing some cookies in the WKWebView. We store the cookies from the NSURLSession response now and append them to the WKWebView manually, by adding "Cookie" header to the HTTP requests.</p>
  
  <p>We were able to get the authorization for HTTP calls work this way, but now we are seeing a new problem. Somehow, all the AJAX calls done in the WKWebView lose the authorization cookies.  </p>
  
  <p>Do you please know if there is any way to somehow have the authorization cookies appear in the AJAX calls too? Injecting javascript with</p>
  
  <pre><code>javascriptCookieString = @"document.cookie = 'testCookie=testValue';";  
  [self.webView evaluateJavaScript:javascriptCookieString completionHandler:nil];
  </code></pre>
  
  <p>did not work and it seems like there is no control whatsoever over Javascript calls, so I cannot alter the requests before they are being executed. Thank you.</p>