Mongoose session store for Express
$ npm install mongoose-store --save
url
: The URL connection formatmongodb://user:pass@host:port/database/collection
. Only need it if there is no connection yet.ttl
(seconds): How long the session persist on the database.
var express = require('express');
var session = require('express-session');
var MongooseStore = require('mongoose-store')(session);
var app = express();
var mongooseStore = new MongooseStore({
url: 'mongodb://127.0.0.1:27017/testing',
ttl: 600
});
app.use(session({
name: 'app.sid',
secret: 'yoursecret',
store: mongooseStore
}));
var express = require('express');
var session = require('express-session');
var MongooseStore = require('mongoose-store')(session);
var app = express();
var mongooseStore = new MongooseStore({
url: 'mongodb://ip1:27017/testing,mongodb://ip2:27017/testing,mongodb://ip3:27017/testing',
ttl: 600
});
app.use(session({
name: 'app.sid',
secret: 'yoursecret',
store: mongooseStore
}));