もちろんできます。
ionicアプリはajaxrequsetを送信するだけで、Cookieは正常に機能するか、サーバーに依存しません。
私はPythonDjangoサーバーとノードサーバーで作業していますが、どちらのCookieも非常にうまく機能しました
以下のノードコード
app.all('*', function(req, res, next) {
res.header("Access-Control-Allow-Origin", '*');
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
res.header("Access-Control-Allow-Credentials",true);
next();
});
残りのAPI
router.get('/setCookies', function(req, res, next) {
var now = new Date();
var nextYear=new Date(now.setFullYear(now.getFullYear()+1));
//you can change the cookie key and value by your self here
res.cookie('cookiesTest', 'set cookies success,your cookies can be set by server', { expires: nextYear, httpOnly: true });
res.status(200)
res.end('SET COOKIES SUCCESS')
});
router.get('/getCookies', function(req, res, next) {
res.status(200)
res.end(JSON.stringify(req.cookies))
});
イオンアプリコード
var server='http://[YOUR IP HERE]:3000'
$scope.setCookies=function() {
$http({
url: server + '/setCookies',
method: 'GET'
}).success(function (data, header, config, status) {
alert('set cookies success,look console')
$scope.setCookiesStatu=false
console.log(data)
$scope.cookiesValue=data
}).error(function (data, header, config, status) {
alert('set cookies error,check console or your server address is wrong')
console.log(data)
});
}
$scope.getCookies=function() {
$http({
url: server + '/getCookies',
method: 'GET'
}).success(function (data, header, config, status) {
alert('get cookies success,look console')
console.log(data)
$scope.cookiesValue=data
}).error(function (data, header, config, status) {
alert('get cookies error,check console or your server address is wrong')
console.log(data)
});
}
ここで私のソースコードを確認できます