I have a few different WKWebViews inside my project they are all sharing cookies over a single WKProcessPool.
Now I want to make a request on a REST API and need to send exactly that cookies from that WKWebViews to that API. Is there a way to get the cookies? Everything I get are the cookies from the
webView and use them for your request.
If they are HTTP-only, it seems that there is no working method to do this.
There is no documented way to sync cookies between
NSURLSession as far as I know.
2) Another approach (if cookies belong to same domain which REST API belongs) - create "background"
webView with same process pool and perform all operations to REST API via this instance - cookies will be added automatically (even HTTP-only):
You can set any params (method/body/headers/etc) to request and load
document.body to get it;
Getting response code a little bit harder - you need to implement
webView:decidePolicyForNavigationResponse: method of
WKNavigationDelegate and catch
Also, you need to keep in mind that you can perform only 1 request
webView simultaneously. So, you may need to create some queue
of requests that will be performed one after another.