Reputation: 697
I am trying to get persistent sessions working using RedisStore but whenever i close the browser the session is destroyed. I tried setting the maxAge and ttl but nothing makes the session survive a browser restart. What am i doing wrong?
The relevant parts of my code are:
var app = express();
var RedisStore = require('connect-redis')(express);
app.use(express.cookieParser('my secret key'));
app.use(express.session({
store: new RedisStore({
host: 'localhost',
port: 6379,
ttl: (60000 * 24 * 30),
cookie: { maxAge: (60000 * 24 * 30) }
}),
secret: 'my secret key'
}));
Upvotes: 4
Views: 1509
Reputation: 791
The cookie should belong in the object you pass to express.session, not in the object you pass to RedisStore.
Try the following:
app.use(express.session({
store: new RedisStore({ host: 'localhost', port: 6379, ttl: (60000 * 24 * 30)}),
cookie: { maxAge: (60000 * 24 * 30)},
secret: 'my secret key'
}));
Upvotes: 8