title: How to get cookies from WKWebView
body: <p>I have this WKWebView which loads a login page and what I need is the "<strong>iPlanetDirectoryPro</strong>" cookie (see picture bellow) that is set after a successful login (form submit). So, I'm trying to store it in order to use it in another WKWebView.. The funny thing is "sharedHTTPCookieStorage" contains the other cookies but not the "<strong>iPlanetDirectoryPro</strong>" one.</p>
  
  <p><a href="https://i.stack.imgur.com/M6lfd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/M6lfd.png" alt="enter image description here"></a></p>
  
  <p>What I tried so far:</p>
  
  <ol>
  <li>Created a shared proccess pool and used the same configuration for this first WKWebView and the one I'm trying to use "<strong>iPlanetDirectoryPro</strong>" on.</li>
  <li><p>I used this delegate method <strong>decidePolicyForNavigationResponse</strong> to fetch cookies:</p>
  
  <pre><code>- (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler{
  NSHTTPURLResponse *response = (NSHTTPURLResponse *)navigationResponse.response;
  NSArray *cookies =[NSHTTPCookie cookiesWithResponseHeaderFields:[response allHeaderFields] forURL:response.URL];
  
  for (NSHTTPCookie *cookie in cookies) {
      [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:cookie];
  }
  
  decisionHandler(WKNavigationResponsePolicyAllow);
  }
  </code></pre></li>
  <li><p>Evaluating JavaScript command document.cookie on webView.   </p></li>
  </ol>
  
  <p>Any ideas?</p>