Following the tutorial steps above, after installing in the Session Support section, connect-mongo add:
Var Mongostore =Require(' Connect-mongo 'expressvar settings = Require ( /settings ' ); and app. (express. Cookieparserapp. (express. Session ({ //...) })
Then run the error:
Error: Most middleware (like session) is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware.
Ask what to do with this middleware in Express 4:
var connect = require (' Connect ');
var session = require (' express-session ');
var Mongostore = require (' Connect-mongo ') (connect);
App.use (Session ({Secret:settings.cookieSecret, store:new mongostore ({db:settings.db})});
I'll be OK with this.
Note : Express 4 is very different from before. For example, Express.session and Express.cookieparser are no longer present. Express and middleware have been stripped apart, except for the express.static.
How to use Connect-mongo in Express 4