Reputation: 565
I've included the cookie-parser before the session (not sure if needed with the current versions), imported express-session as visible. If I change session
to express.session
on line 8 I get a deprecation error (not warning).
var express = require('express'),
cookieParser = require('cookie-parser'),
expressSession = require('express-session'),
port = process.env.PORT || 3000;
app = express();
app.use(cookieParser());
app.use(session({
secret: "yadayada",
resave: true,
saveUninitialized: true
}));
app.get('/', function (req, res) {
console.log(req.session);
console.log(req.cookies);
});
app.listen(port);
Upvotes: 2
Views: 9731
Reputation: 11
same question...... but https://github.com/expressjs/session?_ga=1.45435812.1066105876.1451139756
app.use(session({
genid: function(req) {
return genuuid() // use UUIDs for session IDs
},
secret: 'keyboard cat'
}))
Upvotes: 0
Reputation: 82096
session
is not defined on line 9 because you have it declared as expressSession
at the top i.e.
expressSession = require('express-session')
Either rename the declaration to session
or update line 9 to call expressSession
i.e.
app.use(expressSession({ ... }));
Upvotes: 2