4

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?

user2504522
  • 63
  • 1
  • 6

2 Answers2

3

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?

saigen
  • 186
  • 1
  • 8
1

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.

Hans Knöchel
  • 10,974
  • 8
  • 25
  • 46