Reputation: 63
Does anyone know how to set a WKWebView to pick cookies from NSHTTPCookieStorage ?
I tried injecting the cookie through WKUserScript, but it doesn't work since my page has several redirections, and every page in that redirection uses a cookie.
Any suggestions?
Upvotes: 4
Views: 6099
Reputation: 306
From iOS 11 you get httpCookieStore
for WKWebsiteDataStore
.
https://developer.apple.com/documentation/webkit/wkwebsitedatastore?changes=latest_minor
If you want insert cookies for iOS versions less than iOS 11 (iOS 8 onwards) following link will help
Can I set the cookies to be used by a WKWebView?
Upvotes: 3
Reputation: 11552
Cookies are not supported in the WKWebView
so far. Many attempts (using NSHTTPCookieStorage
, the WKWebsiteDataStore
and evaluated document.cookie;
) all do not work.
You can follow this bug-report for the issue and possible patches, I hope that answers your question for now, although it doesn't solve it.
Upvotes: 1