Open insraq opened 7 years ago
Any thoughts on this? https://github.com/CRAlpha/react-native-wkwebview/pull/67
I'm using WkWebView to reuse my website's authentication system (fairly complex and cant easily be extracted into an api / oauth flow). So I'll need to watch and pull out a cookie from the environment once the user is logged in.
Maybe instead of patching the current WKWebView we can implement proper cookie-handling in this component, when iOS11 is out. With iOS11 Apple seems to have added the proper tools to handle cookies:
https://developer.apple.com/documentation/webkit/wkhttpcookiestore (info video: https://developer.apple.com/videos/play/wwdc2017/220/)
@wireforce I agree we should implement WKHTTPCookieStore
. Feel free to make a PR if you are interested.
After the v1.17.0 release this component actually works fine for my use case (Several webviews that needs to share the session cookies and local storage). I cant grab the cookies that are set in the webviews (as I would if WKHTTPCookieStore was used), but I don't need to do that right now. So I'm happy :)
This issue will probably take some time. We are not actively working on it (since we don't really use this). So any contribution is welcome. This will address some of the issues in PR #49.
NSHTTPCookieStorage
todocument.cookie
. This will enable AJAX requests to share the cookie. You can simply usedocument.cookie = newCookie;
to set/update cookies.updateCookie
to force an update fromSet-Cookie
header toNSHTTPCookieStorage
. I believeSet-Cookie
will eventually end up inNSHTTPCookieStorage
, it's just a matter of when.webView:decidePolicyForNavigationResponse:decisionHandler:
andWKUserScript
.