问题描述
我一直在使用Ionic构建一个Android应用程序。在这一点上,我的印象是,Cordova应用程序不保存或发送从REST API服务器提供的cookie。如果我使用'ionic serve'命令运行应用程序,我可以看到我的会话和CSRF cookie与我的AJAX请求一起发送。但是,当我使用'ionic emulate'命令运行代码时,它不会显示发送到我的服务器。
我看到一些文章和线程关于在扩展CordovaActivity的类中使用setAcceptThirdPartyCookies()方法,但是对我来说没有效果。
我试过使用$ httpProvider.defaults.withCredentials = true在我的角度模块配置无效。
我已经尝试使用ngCookies,但是似乎没有从我的API服务器的cookie的处理。 / p>
我只是想知道一次,如果在Cordova应用程序中使用cookie可能与否。如果不是,我会用基于令牌的方法去。
您可以使用移动应用程序和网络应用程序来使用相同的安全配置。 t使用cookie,您应该使用localStorage
请参阅了解详情
I have been building an android app using Ionic. At this point, I am under the impression that Cordova applications do not save or send the cookies that are served from a REST API server. If I run the application with the 'ionic serve' command I can see that my session and CSRF cookies are sent with my AJAX requests. However, when I run the code with the 'ionic emulate' command it does not appear that either are sent to my server.
I have seen some articles and threads that talk about using the setAcceptThirdPartyCookies() method in the class that extends CordovaActivity, but that hasn't worked for me.
I have tried using $httpProvider.defaults.withCredentials = true in my angular module config to no avail.
I have tried using ngCookies, but that doesn't appear to get a handle on the cookies from my API server either.
I just want to know once and for all if using cookies in a Cordova application is possible or not. If it isn't I will go with a token based approach. It would be nice to be able to use the same security configuration for the mobile app and web app though.
You can't use cookies, you should use localStorage
See this for details
这篇关于您可以在Cordova应用程序中使用Cookie吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!