Giter Site home page Giter Site logo

Comments (10)

finalquest avatar finalquest commented on June 14, 2024 5

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.

felixmeziere avatar felixmeziere commented on June 14, 2024 1

@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 to true.
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.

KoenLav avatar KoenLav commented on June 14, 2024 1

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.

felixmeziere avatar felixmeziere commented on June 14, 2024

This is blocking us too :/

from react-native-webview.

Titozzz avatar Titozzz commented on June 14, 2024

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.

epiceros avatar epiceros commented on June 14, 2024

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.

Titozzz avatar Titozzz commented on June 14, 2024

Ok, thanks for the details. If you want to start working on it I can review / merge pull requests 🚀

from react-native-webview.

Titozzz avatar Titozzz commented on June 14, 2024

Good insight, thanks

from react-native-webview.

kylemantesso avatar kylemantesso commented on June 14, 2024

I've raised a PR to fix this issue

from react-native-webview.

github-actions avatar github-actions commented on June 14, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.