Cordova-plugin-ionic-webview: Custom HOSTNAME / SCHEME break cookies support

Created on 20 Feb 2019  路  2Comments  路  Source: ionic-team/cordova-plugin-ionic-webview

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.

Most helpful comment

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?

All 2 comments

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?

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lincolnthree picture lincolnthree  路  7Comments

begbeder picture begbeder  路  5Comments

alexverbitsky picture alexverbitsky  路  3Comments

Git-Santhosh picture Git-Santhosh  路  5Comments

50l3r picture 50l3r  路  7Comments