I have a database in mongo to store session state called 'SessionStore' with a collection called 'Sessions' to store session state.
I'm using expression-session for managing sessions.
Code to setup sessions is as follows;
var session = require('express-session');
var MongoStore = require('connect-mongo')(session);
.
.
.
var sessionDb = 'SessionStore';
var sessionCollection = ['Sessions'];
var mongojs = require('mongojs');
var ObjectId = mongojs.ObjectId;
var dbSessions = mongojs(sessionDb, sessionCollection);
.
.
.
app.use(session({
secret: 'mysessionsecret',
name: 'connectionEngine',
store: MongoStore({db: dbSessions}),
proxy: true,
resave: true,
saveUninitialized: true
}));
Except when it gets to the last line it fails with the following;
C:\Users\Paul\Documents\Visual Studio 2015\Projects\Connection-Engine\Connection-Engine\node_modules\connect-mongo\lib\c
onnect-mongo.js:126
self.emit(newState);
^
TypeError: undefined is not a function
at changeState (C:\Users\Paul\Documents\Visual Studio 2015\Projects\Connection-Engine\Connection-Engine\node_modules
\connect-mongo\lib\connect-mongo.js:126:12)
at MongoStore (C:\Users\Paul\Documents\Visual Studio 2015\Projects\Connection-Engine\Connection-Engine\node_modules\
connect-mongo\lib\connect-mongo.js:237:5)
at Object.<anonymous> (C:\Users\Paul\Documents\Visual Studio 2015\Projects\Connection-Engine\Connection-Engine\app.j
s:100:12)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.runMain [as _onTimeout] (module.js:501:10)
at Timer.listOnTimeout (timers.js:110:15)
I think I have missed some part of the set-up but I am not sure what. Can anyone suggest something.