をすることができます。
イオンアプリはAJAXを送信するだけで、クッキーは正常に動作するかサーバーに依存しません。
私は両方のクッキーが
ノードコード
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)
});
}
、PythonのDjangoのサーバーとノードサーバとの仕事を持っています
you can check my sourse code here
すべてのスクリプトがlocalStorageにアクセスできますか?私はそれが別々のPhoneGapアプリごとにちょっとしたサンドボックスだと思った...いいえ? – jayarjo
ここに:http://stackoverflow.com/questions/15184567/is-local-storage-for-a-phonegap-app-on-an-android-device-separate-from-the-built – jayarjo
このプラグインは役に立ちますか? https://github.com/assembly/cordova-cookie-jar –