Cookies used (created) by the WKWebView
are actually correctly stored in the NSHTTPCookieStorage.sharedHTTPCookieStorage()
.
The problem is that the WKWebView
does not write back the cookies immediately. I think it does this on its own schedule. For example when a WKWebView
is closed or maybe periodically.
So eventually they do end up in there, but when is unpredictable.
You may be able to force a ‘sync’ to the shared NSHTTPCookieStorage
by closing your WKWebView
. Please let us know if this works.
Update: I just remembered that in Firefox for iOS we force the WKWebView
to flush its internal data, including cookies, by replacing its WKProcessPool
with a new one. There is no official API, but I am pretty sure that is the most reliable workaround right now.