From 0f60751d5e54c5c37a5014264e8a91f170949868 Mon Sep 17 00:00:00 2001 From: "Eduardo L. Buratti" <elb09@c3sl.ufpr.br> Date: Thu, 14 Nov 2013 10:29:09 -0200 Subject: [PATCH] web: Add sqlite3 storage for sessions (sticky sessions) Signed-off-by: Eduardo L. Buratti <elb09@c3sl.ufpr.br> --- web/.gitignore | 2 ++ web/package.json | 3 ++- web/server.js | 7 ++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/web/.gitignore b/web/.gitignore index c48746a..3dabfa2 100644 --- a/web/.gitignore +++ b/web/.gitignore @@ -19,3 +19,5 @@ app/js npm-debug.log config.js + +sessions.db diff --git a/web/package.json b/web/package.json index adb42f7..6890e07 100644 --- a/web/package.json +++ b/web/package.json @@ -13,6 +13,7 @@ "express": "~3.3.8", "connect": "~2.9.0", "grunt-contrib-uglify": "~0.2.4", - "grunt-contrib-concat": "~0.3.0" + "grunt-contrib-concat": "~0.3.0", + "connect-sqlite3": "~0.9.2" } } diff --git a/web/server.js b/web/server.js index 3c90a47..1beb80f 100755 --- a/web/server.js +++ b/web/server.js @@ -3,6 +3,7 @@ var express = require('express'); var config = require('./config.js'); var db = require('./middleware/db.js'); +var SQLiteStore = require('connect-sqlite3')(express); var sessions = require('./routes/sessions.js'); var points = require('./routes/points.js'); @@ -15,7 +16,11 @@ var app = express(); app.use(express.logger('dev')); app.use(express.bodyParser()); app.use(express.cookieParser()); -app.use(express.session({ secret: config.secret })); +app.use(express.session({ + store: new SQLiteStore, + secret: config.secret, + cookie: { maxAge: 7 * 24 * 60 * 60 * 1000 } // 1 week +})); app.use(express.static(__dirname + '/app')); db.config(config.db_config); -- GitLab