Comments (10)
Me again.
We have been strugling with cookies errors on wkwebview from the start.
The way wkwebview handles cookies on iOS is pretty rare.
In the old UIWebview, the cookies are shared between all the network requests of the application.
So, for example, I logged to a server using fetch on RN, the webview can keep a session without login, because the cookie session is already setted by the first fetch.
WKWebview dosnt work like this. I've made several attempst to fix that on the react-native-wkwebview repo, but I failed every time.
So, if anyone has any insight on this, I will gladly accept it
Regards
from react-native-webview.
@epiceros @Titozzz found an improvable fix for this for now:
- Add master branch of react-native-cookies to your package.json:
"react-native-cookies: "git+https://github.com/joeferraro/react-native-cookies"
- Install/link the library properly.
- Get the cookies of the website you need and then set them with the hidden option
useWebKit
set totrue
.
const cookies = await CookieManager.get('http://example.com')
CookieManager.set({
name: 'myCookie',
value: cookies.myCookie.value,
domain: cookies.myCookie.domain,
origin: cookies.myCookie.domain,
path: cookies.myCookie.domain.path,
version: '1',
expiration: cookies.myCookie.expiresDate
}, true) // <= true here!!!
You might just need the set
part.
Not sure of what's really needed and not in this, I don't have time to investigate more on it. If you find a quicker way of doing it please tell us here :-)
from react-native-webview.
This should already be fixed here:
CRAlpha/react-native-wkwebview@3e01629
Please consider replacing WKWebView with this better maintained version, per my suggestion here: #105
from react-native-webview.
This is blocking us too :/
from react-native-webview.
Can you give more details about your environment? Does this only apply to wkwebview? Is it fine on Android and UIWebview ? Do you have multiples Webview a t the same time or only one that you close then reopen ?
from react-native-webview.
Hi! Some more info. We have an app with one main webview where, the user logs in. Then at times we overlay that webview with another webview, where the user needs to be logged in (so they are both open at the same time, and they are on the same domain). The webview displays fine, but the user is not logged in, in the overlaying webview. This is only the case for WKWebView, in UIWebView, and on Android, it just works.
from react-native-webview.
Ok, thanks for the details. If you want to start working on it I can review / merge pull requests 🚀
from react-native-webview.
Good insight, thanks
from react-native-webview.
I've raised a PR to fix this issue
from react-native-webview.
Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically
from react-native-webview.
Related Issues (20)
- Proxy logic in a Webview HOT 1
- UIKit/UIKit.h file not found when using RCT_NEW_ARCH_ENABLED HOT 1
- NSInvalidArgumentException: -[RNCWebViewImpl destroyWebView]: unrecognized selector sent to instance 0x10b1e9a00 HOT 11
- Scrolling not working when webview inside scrollview and user try to scroll scrollview pressing webview in android. HOT 2
- Crash to open app after installing react-native-webview HOT 4
- Webview not opening link - only on Android released versions HOT 2
- Custom header on subsequent GET request do not work even with method suggest in react-native-webview guide HOT 2
- [Android / New Arch] `injectJavaScript` and presumably other commands get executed twice HOT 6
- LIBRARY STATUS CHECK HOT 2
- View config getter callback for component RNCWebView must be a function (received undefined) HOT 3
- Prevent URL scheme/ Universal Links loading on iOS HOT 1
- Video playing on Android emulator and debug apk. But not on Release apk. Showing black screen. HOT 1
- Showing error HOT 1
- remove android camera permission by using android intent HOT 1
- [Android & iOS] Calling `window.print()` inside an HTML document has no effect HOT 5
- Error : Tried to register two views with the same name RNCWebView in Expo HOT 2
- onShouldStartLoadWithRequest not working on Android
- TypeError: Cannot read property 'startLoadWithResult' of null, js engine: hermes HOT 8
- Windows app crashes whenever I use WebView2 HOT 2
- Allow localstorage HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-webview.