'session' is undefined when using express / redis for session store 'session' is undefined when using express / redis for session store express express

'session' is undefined when using express / redis for session store


Sessions won't work unless you have these 3 in this order:

app.use(express.cookieParser());app.use(express.session());app.use(app.router);

I'm not sure if router is mandatory to use sessions, but it breaks them if it's placed before them.


Looks like you're missing:

app.use(express.cookieParser());

before your app.use(express.session(...)); call.

See here.


Had the same problem, however it was caused by changes in the latest version of express.

You now need to pass express-session to the function connect-redis exports to extend session.Store:

var express = require('express');var session = require('express-session')var RedisStore = require('connect-redis')(session);