From 3d1b6369a21023ea3132fd8337b8d1148f52584e Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Mon, 16 Sep 2013 19:16:12 +0200 Subject: [PATCH] [TASK] Store lastActivity as string instead of date. --- app.js | 2 +- src/Session.api.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app.js b/app.js index 86b5415..85d778e 100644 --- a/app.js +++ b/app.js @@ -57,7 +57,7 @@ app.use(function(req, res, next) { "user": null, "profile": {}, "login": false, - "lastActivity": new Date() + "lastActivity": new Date().toString() }; } console.log(["Session Data", req.session.data]); diff --git a/src/Session.api.js b/src/Session.api.js index f4f3599..6269fca 100644 --- a/src/Session.api.js +++ b/src/Session.api.js @@ -10,8 +10,8 @@ var constructor = function(db) { //refresh session and return login status if(req.method == "GET") { if(req.session.data.login == true) { - if(new Date() - req.session.data.lastActivity < 5 * 60 * 1000) { - req.session.data.lastActivity = new Date(); + if(new Date() - new Date(req.session.data.lastActivity) < 5 * 60 * 1000) { + req.session.data.lastActivity = new Date().toString(); } else { req.session.data.login = false; } @@ -57,7 +57,7 @@ var constructor = function(db) { } if(!err && match == true) { req.session.data.login = true; - req.session.data.lastActivity = new Date(); + req.session.data.lastActivity = new Date().toString(); res.send(200, JSON.stringify({ "success": true }));