ionic-team / cordova-plugin-ionic-webview

Web View plugin for Cordova, specialized for Ionic apps.
Apache License 2.0
484 stars 392 forks source link

Custom HOSTNAME / SCHEME break cookies support #312

Open FarhadG opened 5 years ago

FarhadG commented 5 years ago

I've build a simple POC showcasing cookies working with the WkWebView (using this plugin). It works great with the default hostname and scheme (i.e. ionic://localhost). However, after changing the hostname and/or scheme, cookies no longer work.

Here's a the link the REPO with steps on how to reproduce the issue.

Thank you, in advance, for the help.

EiyuuZack commented 5 years ago

On your POC's README.md it is mentioned:

Although cookies work with default settings, they are never visible. That is, developers cannot inspect cookies inside of Safari's devtools (under application cookie storage).

Another thing I've noticed is that document.cookie is always empty. I have removed the httpOnly flag from the cookie header sent in the response but it never shows up in document.cookie.

What is even weirder is that if you use Safari's devtools to set a cookie (e.g. document.cookie="foo=bar") it is not set and document.cookie remains empty, meaning JavaScript has no access to any cookies whatsoever.

Any ideas why this happens?

afulkersonApollo commented 3 years ago

Can someone please give a clear explanation as to why cookies aren't available in the webview in iOS? I can get cookies to work AND THEY ARE VISIBLE IN DEV TOOLS if I set the hostname setting in capacitor.config.js to the same domain as the requests I'm making BUT the app we're creating is designed to be used with backends located at addresses the user inputs.