我正在寻找使用node.js,express和neo4j作为数据库来存储我的会话。如何将会话存储在内存中?我正在寻找一种方法来存储我的会话neo4j数据库或替代
var express = require('express');
var path = require('path');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var session = require('express-session');
var routes = require('./routes/index');
var app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
// uncomment after placing your favicon in /public
//app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use(session({
secret: 'keyboard cat',
resave: false,
saveUninitialized: true,
cookie: {maxAge:86400000, secure: true}
}));
.
.
.
答案 0 :(得分:1)
var session = require('express-session');
var sessionstore = require('sessionstore');
var routes = require('./routes/index');
var app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
// uncomment after placing your favicon in /public
//app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use(session({
store:sessionstore.createSessionStore(),
secret: 'this is the big secret every body is fussing abt',
resave: false,
saveUninitialized: true
}));
答案 1 :(得分:-1)
使用An advanced session store for Redis for node.js
这很容易集成到您的系统中。