Alvaro
Alvaro

Reputation: 41595

How to use cookie-session for node expresss.js

As express-session is not ready to work on production environments unless you change the module to something like redisStorage, I decided to go for cookie-session.

The documentation doesn't seem to be very clear to me. It says

Other options are passed to cookies.get() and cookies.set()

I was trying to use cookieSession as express-session, but it seems that's not the way it works:

var cookieSession = require('cookie-session');

app.use(cookieSession({
  maxAge: 20*60*1000, //20 mins
  httpOnly: true,
  secure: true,
  secureProxy: true,
  keys: ['key1', 'key2']
}));

Upvotes: 2

Views: 98

Answers (1)

Alvaro
Alvaro

Reputation: 41595

I was in fact doing it in the right way. But because the documentation can be confusing I was not certain.

This answer helped me to understand what documentation really means.

Upvotes: 1

Related Questions