cookies icon indicating copy to clipboard operation
cookies copied to clipboard

Move WebKit related cookie logic to react-native-webview

Open safaiyeh opened this issue 5 years ago • 2 comments

Should WebKit cookies be moved to the react-native-webview module?

The only time WebKit cookies are needed is usage with WebView. The two are coupled.

How would y'all feel about moving that functionality over or is there another way that this can be handled?

Issue in react-native-webview: https://github.com/react-native-community/react-native-webview/issues/1139

safaiyeh avatar Jan 14 '20 02:01 safaiyeh

I'm a bit hesitant on this, mainly due to the behavior on android

After the deprecation of UIWebview, the behavior is currently this:

Setting BOTH WebView AND React-Native fetch cookies Setting ONLY WebView cookies Setting ONLY React-Native fetch cookies
Android .set(url, cookie) n/a n/a
iOS n/a .set(url, cookie, true) .set(url, cookie)

If the webkit-cookie functionality were to be relocated into the react-native-webview library, the functionality of this library would be imbalanced: fetch+WebView cookies on Android, but only fetch cookies on iOS.

If the android functionality could be separated, that might change the story, but it looks like it's CookieManager all around.. not possible to separate fetch/WebView cookies on Android.

Another consideration is that other webview plugins could exist beyond react-native-webview. That is definitely the dominant one for now, but I think it is nice that the cookie-store functionality lives in this package.

Another option is to unify the default behavior on iOS behind the scenes: let set(url, cookie) modify both NSHTTPCookieStorage AND WKHTTPCookieStore simultaneously. This definitely has downsides.. and what would get() do? Retrieve from one? Both & merge cookies? It becomes complicated.

It's nice when RN libraries expose the "full" native functionality, so the ability to interact with both cookie stores independently should definitely stay, but on the other hand, similar default behavior between iOS and Android could be nice.

davidgovea avatar Aug 14 '20 16:08 davidgovea

@davidgovea I appreciate the chart! Visualizes how cookies works.

I always aim for similar default behavior, then added platform specific customizations.

safaiyeh avatar Aug 18 '20 19:08 safaiyeh