4
votes

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?

2

2 Answers

3
votes

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?

1
votes

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.