document.cookie non functional in ios 6.0.0/6.1.0
See original GitHub issueBug Report
Using
<preference name="scheme" value="app" />
<preference name="hostname" value="localhost" />
renders document.cookie completely non-functional.
What is expected to happen?
To see this just do
cordova create myApp org.apache.cordova.myApp myApp
cd myApp
(add scheme and hostname preferences to config.xml)
cordova platform add ios@^6.1.0
Now load myApp into the emulator from xcode, then go to the Safari web inspector and try
document.cookie="foo=bar"
document.cookie
Result is empty string.
Removing the scheme and hostname preferences enables document.cookie, but then you don’t have the benefit of the scheme.
With ios 5 I used cordova-plugin-wkwebview-file-xhr to enable loading both local and remote urls, and cordova-plugin-wkwebviewxhrfix to enable Javascript trap information to be passed to my code.
With ios 6.1.0 I am still using cordova-plugin-wkwebview-file-xhr (I just removed the dependency on the wkwebview plugin) and this removes the need for the scheme and hostname preferences. However, the scheme and hostname preferences are necessary for Javascript trap information to be passed to my code (other people have commented that cordova-plugin-wkwebviewxhrfix is not compatible with ios 6.0.0).
Command or Code
See above
Environment, Platform, Device
Mac Mini, iPhone 11 xcode simulator
Version information
Cordova 9.0.0, Cordova ios 6.1.0, xcode 11.5
Checklist
- I searched for existing GitHub issues
- I updated all Cordova tooling to most recent version
- I included all the necessary information above
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:12
Top GitHub Comments
I can confirm this.
document.cookie = ‘test’
will be ignored with cordova-ios@6.0.0 or 6.1.0
Additionally, server cookies within the response won’t be set.
The last behaviour is most likely related to WKWebview and seems to be some kind of Safari “feature”.
Source: https://bugs.webkit.org/show_bug.cgi?id=140205
We also used the cookie emperor plugin and can confirm that with cordova 6.1.0 this plugin is not working anymore. We need this really bad. Does anyone has an alternative solution to get cookies?