apache / cordova-ios

Apache Cordova iOS
https://cordova.apache.org/
Apache License 2.0
2.16k stars 989 forks source link

Unable to set and sync cookies on WKWebview #1029

Closed aishwarya1422 closed 3 years ago

aishwarya1422 commented 3 years ago

PLATFORM AND VERSION iOS InAppBrowser v4.0.0 Cordova-ios v6.1.1

DESCRIPTION OF PROBLEM We need solution with which we can sync the cookies between requests made from inAppBrowser and WKWebview

How application works

Description of Issue

We are trying to display web pages using the Object tag in the index.html file of Cordova application and the content is not getting rendered due to loss of sessionId.

The user gets logged out and it cannot access the application further , it is important for the cookies to persist for the application to work .

Expected Result

We want to sync the cookies so that it is available for every request we make from our application .

Note - The apps were working with UIWebview with the latest iOS v14.2 .

Solution tried - Tried adding this plugin https://github.com/CWBudde/cordova-plugin-wkwebview-inject-cookie and it didn’t work

STEPS TO REPRODUCE Set the cookie from inappbrowser and try to get the same in webview. unable to get the cookie.

NiklasMerz commented 3 years ago

3rd party cookies and WKWebView on iOS 14 is a problem since WebKit enables tracking prevention starting with iOS 14. You probably need to do your own research on how to fix this.

You may need to redesign your application to not rely on third party cookies. Adding third party content to your main webview in object tags sounds not like a good and secure solution as well.

Here my experience with this: https://blog.merzlabs.com/posts/webview-history/

And this could help too: https://webkit.org/blog/10882/app-bound-domains/

I am closing this issue because it is not something Cordova can fix.