-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cookies not being sent to webview for iOS #188
Comments
One thing that could be causing this is that you are not setting the webkit boolean to true here: |
Thanks @karel-suchomel-ed! That fixed it for the initial Webview load, but when I leave the webview and then return to it, the cookies are not being synced and I am back to the sign in screen. Any ideas on why re-entering the Webview, the cookies don't work?
|
I think that for your use case you could use something similar that I used for sharing sessions between RN and WebView.
The key was to set the cookie before every webview mount. I didn't experience any false positives this way, even tho the documentation warns about this. If you need to persist browser history between WebView mounts, you could write your own logic and handle the URL with state. I was using this hook for managing the history stacks:
I only reset the cookies for Android, because I had some issues overwriting other cookies there. You should also store that session cookie in secure storage (MMKV for example), so you can set it before WebView load, because session cookies are wiped. I took inspiration from this: https://stackoverflow.com/questions/62057393/how-to-keep-last-web-session-active-in-react-native-webview but instead of passing the cookie through cookie header in source I set it via the CookieManager. |
Bug description:
Web view should be rendering a web page that has a cookie authentication. Instead it is rendering sign in page. This is happening on iOS after I upgraded to react native 0.73+. It was working properly before the upgrade. Android is working fine.
I have both
thirdPartyCookiesEnabled={true}
andsharedCookiesEnabled={true}
enabled. Also inhandleNavigationStateChange
I reset the cookies for iOS:I also tried to sync the cookies manually with this in the
onLoad
and theonNavigationStateChange
of<WebView />
, but it still didn't work.Expected behavior:
Web view should render account page, not sign in page
Environment:
The text was updated successfully, but these errors were encountered: