passport: Passport.js does not work with cookieSession (Express.js)
I’m using Passport to log in with Facebook or Twitter into my service. Since MemoryStore is not intended for production and I’m not going to store much information into the session, I wanted to use cookieSession, but it doesn’t work:
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser());
app.use(express.cookieSession({ secret: 'keyboard cat', cookie: {maxAge: 60 * 60} }));
app.use(passport.initialize());
app.use(passport.session());
app.use(app.router);
It works as expected if I repace cookieSession() with session():
app.use(express.session({ secret: 'keyboard cat' }));
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 15 (2 by maintainers)
SOLVED! 😄
It was my fault, nothing to do with passport. I was provisionally serializing full facebook profile into the session (like you did in the passport-facebook project’s example), without taking into account that it doesn’t fit into a cookie! That’s why it was working using the default MemoryStore and failing with cookieSession. It works as expected if you serialize less information.
Hope it helps, @mlehtinen 😃.