-
Notifications
You must be signed in to change notification settings - Fork 358
Cookies are not set/stored in iOS #77
Comments
Same issue here. I installed this plugin in my Cordova project and cookies work fine on Android but not on iOS! :( |
We've been using https://github.com/oracle/cordova-plugin-wkwebview-file-xhr which works for us |
Thanks for the response, @adam-h! I took a look and spent a few hours trying to read cookies in my iOS WKWebView, however, no luck :( Do you have any examples for me to reference to see if I'm doing anything incorrectly? I'm making a simple request with the following: // index.js inside of Cordova application
const xhr = new XMLHttpRequest();
xhr.addEventListener('loadend', function(evt) {
console.log({ evt, response: this.response });
});
xhr.open('GET', 'http://localhost:8000/api');
xhr.send(); And here's the mockserver attaching cookies to every request: // server.js
const cors = require('cors');
const express = require('express');
const cookieParser = require('cookie-parser');
const app = express();
app.use(cookieParser());
app.use(cors());
app.get('*', (req, res) => {
res.cookie('username', 'john doe', { maxAge: 900000, httpOnly: true });
res.send('Hello World!');
}); Unfortunately, I don't see any cookies in the Cordova application after the server has responded. |
Oh, sorry no the patch plugin I linked will only make server side cookies function (so things like login will often just work) - it won't allow you to get/set them from the client. The way it works is by redirecting all requests to go via native code, rather than through the webview. |
Thanks, @adam-h! That's what I suspected but for some reason, this plugin didn't work for me. I assume it's because I'm using the That being said, this one did exactly the same functionality: https://github.com/aporat/cordova-plugin-fetch |
I have the same issue. My stack is similar to @FarhadG's (cordova + react). Replacing UIWebView with WKWebView I lost access to all my cookies -- In fact, opening the Safari inspector and setting UIWebView: I find this extremely odd... |
Is this reproducible in a new, plain Cordova app? A minimal reproduction repository would really help to debug and later fix this issue. More information on how to create one: https://github.com/apache/cordova-contribute/blob/master/create-reproduction.md (Without this, a maintainer has to spent quite some time to first produce one.) |
I use |
I have the same issue. |
I have the same issue. |
same here |
Here is my solution to set the cookies in ios devices but its not working in simulators |
I have the same issue. Seems very serious. |
Can anyone please help here... |
Any progress in that issue? |
this is my working solution for this issue also working on ios 14 |
Do you have any examples of usage? I have a problem with using it |
I have the same problem with fresh install and start app the first time. Login screen is succesfully showed. I fill and submit credentials and try connect to socket.io. Connections failed with error - Unable to connect Socket.IO Missing cookie header. When kill app a start again everything works fine. To you have any solutions to fix this issue? I tried plugin https://github.com/lucky3491/cordova-plugin-wkwebview-inject-cookie but doesnt work. |
This plugin (https://github.com/lucky3491/cordova-plugin-wkwebview-inject-cookie) never worked for me. I had to detect iOS platform and in that case manually add the 'Cookie' request header to every XHR call. |
hlo guys i am using this plugin in ionic 1 project like this Simply add this code in your project and then check your request header |
Like @breautek mentioned in apache/cordova-ios#883 (comment) you could give If anyone has any idea how to solve the issue when loading HTML assets (image for instance via |
In simulator it is not working but have you tested with real devices, can you please make sure about it. Thanks |
Hi @lucky3491 , can i actually inject any cookie into WKWebView using your I tried using your plugin and injecting cookies (extracted with cordova-cookie-emperor) like described in your README but can't make it work (sorry to repeat myself), to load remote HTML assets like images, audio or videos via HTML tags like |
@iwan-uschka have you found solution for that? We faces with the same problem, loading resources. |
@StasKalishenko No, unfortunately. But if you are the owner of the corresponding API you could think about a workaround like using access tokens (as a substitute for cookies) as query param in source URLs. For instance
Where to get the accessToken from?
Hope this helps. |
For those arriving here from google, you should know that cordova iOS 6.0.0 uses WkWebView out of the box, and this plugin is no longer supported/required. There are still issues with that, however, and I'd encourage you to share some votes/contributions to the following:
|
How do you solve it now |
We are archiving this repository following Apache Cordova's Deprecation Policy. We will not continue to work on this repository. Therefore all issues and pull requests are being closed. Thanks for your contribution. |
Since we upgraded from the old
UIWebView
engine, we are not able to authenticate our users (using an external auth service), as none of the cookies sent by the APIs are being set in the this web view.This is a major blocker for us and have been trying to determine what a good course of action is. If our assumptions are correct that cookies are not supported with this web view (which is very strange), we are going to try:
Our stack:
The text was updated successfully, but these errors were encountered: