-
Notifications
You must be signed in to change notification settings - Fork 393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cookies Ignored on First Application Execution #22
Comments
I have the same issue, cookies not working the first time. |
Same issue here. I don't think there is a solution in this fork. This is really a blocker for us in user experience. Please take a look at this! |
This also causes websockets to break on many apps that rely on sticky session cookies to connect to the same server. Even if you were to use localstorage for auth, it's hard to get around the sticky session issue. |
This fork seems to have fix for this issue: https://github.com/agarcia17/cordova-plugin-wkwebview-engine |
Yikes, that is one heavy handed fix. |
@mukana-lahtelat I don't think this fixes XHR requests, it seems to only deal with the |
I also seem to be experiencing this issue, but for me the cookies don't ever seem to be sent or stored even when I restart the application (using a simulator). I can see |
+1. |
+1 |
+1 |
I uninstall WKWebView plugin then reinstall ios platform, so it working now. |
This appears to be causing problems for me as well |
When you will call first the same request using cordova-plugin-fetch, it will "unlock" saving set-cookie header in next normal request. That fixes issue when app is opened first time after installation. But it's not so elegant solution ;) ... |
I'm using in my app cordova-plugin-file-transfer to download/save files on device. In request there is no cookie header, even when app is not first opened on device. Looks like above solution with cordova-plugin-fetch solves that issue .. Maybe it will help someone to better investigate and solve that issue. |
+1 edit: |
fix issues. ionic-team#22 workaround copied from https://www.jianshu.com/p/85f24794bbea,thanks to author 狍子君.
What happened to the PR ? Did it work? Why was it not merged? |
Has anyone found a fix for this issue that is not listed here? Is anyone from Ionic working on this at all? |
+1 Would also love to see a working fix! |
+1 Please fix this issue. |
I've made a workaround for this so that the cookies work again after the first startup of the app. For that I created this plugin based on a different persons advice. If i find the Person again ill give him credit here and in the plugin of course: https://github.com/COMLINE-AG/native-xhr-plugin/ This will make the use of cookies possible again. |
So do a native request and wait 3 seconds? Really? |
@oliverjanik Well there is no real alternative for this until Ionic fixed this issue. I've tried many workarounds, but this workaround was the only one that worked. If u have concerns about the 3 seconds of waiting, then make a request on application startup. If the user has to enter login data then the 3 seconds have passed already and the user will notice nothing about it. Edit: I forgot to mention that u need to do this native request once. After this request and the wait of 3 seconds u can use normal xhr again. |
I tried most of the wkwebview xhr workarounds and went with this one:
|
@asrytis do you use that to do all you ajax calls then? |
Are there any news on this? |
I think you need to get Apple to fix their Webview, to solve this, cleanly. |
@marecektn Do you have a link to any doc page on how/why this preference is used? I can't seem to find anything related to it. Thanks! |
@l3ender I am not aware of any documentation about this. I've just realised it during debugging. Trial & error. That's why I commented on this post since it is really time consuming to find. |
Thanks @marecektn that solved our issue with cookies not being persisted inside an iframe in our Ionic Capacitor app. |
Thanks @marecektn |
That's indeed a good workaround for some situations. Thank you for sharing. From iOS 13 WKWebView ignores cookies completely if the request is cross-origin. That's why I filed this Webkit bug. |
Here is a good summary of cookies/XHR CORS -related issues around WKWebView from the Cordova blog: https://cordova.apache.org/news/2018/08/01/future-cordova-ios-webview.html |
Thank you for the wonderful introduction of the plugin. |
This worked for me. |
Thank you very much @marecektn
It will change your ionic address to capacitor://yourdomain.com and cookies are passing correctly |
Thanks! |
Here is my solution for cookie problem in ios devices |
I have tried changing the host name and the https://github.com/lucky3491/cordova-plugin-wkwebview-inject-cookie with no luck. Are there any other workarounds for this? |
Works on ios and doesn't work on android. |
Can i use |
I'm having similar issues than @Elardzhi Initially we think it could be related to Doing some debugging on the browser through simulator, we get this reponse headers (note the shouldInterceptRequest the same as if we were using
We need to set the Line 0 - Msg: Failed to load https://mydomain.com/app/config: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://mydomain.com' is therefore not allowed access. Our final version of "server": {
"androidScheme": "https",
"hostname": "mydomain.com",
}, And same results than @Elardzhi , it works on iOS but not on android because we get a local request instead |
This actually worked for me after an excruciating amount of troubleshooting but now the problem is that users of our app are going to be making requests to potentially more than one backend which makes this particular setting useless to us. Any ideas other than using a native plugin? |
@afulkersonApollo an option might be to proxy these multiple backends / microservices through an endpoint on your main host, using something like http-proxy-middleware:
|
If there are multiple domain.. |
If so, why is it only ignored for the first time。If the Hostname is not set, the cookie will be synchronized the second time startup |
bump? |
It appears that the same goes for ios now too, it'll create a local request as of recent changes (not more than 3 months) |
When installing a fresh build of my application and attempting to log in, it fails because the authentication cookie sent by the server is never stored. Closing the application and re-launching fixes the issue. There is an identical issue for
cordova-plugin-wkwebview-engine
here. Is this one of the issues that has been / will be fixed in this fork, or is there a viable workaround at this time?The text was updated successfully, but these errors were encountered: