问题
I use in my project express and passport for working with session and it works fine instead of one problem. When i close browser my session deserialized and this is fine, but i need to be logined after connecting again. Should i save information in cookies or use another package in npm? A little bit about my code:
app.use(session({
secret:'secret',
maxAge: new Date(Date.now() + 3600000),
httpOnly: true,
cookie: { path: '/', httpOnly: true, maxAge: null},
store: new MongoStore(
{mongooseConnection:mongoose.connection},
function(err){
console.log(err || 'connect-mongodb setup ok');
})
}));
app.use(passport.initialize());
app.use(passport.session());
As you can see i use a common passport+express program. Just give me any good tips for searching.
回答1:
Solution is change cookie: { path: '/', httpOnly: true, maxAge: null} to cookie: { path: '/', httpOnly: true, maxAge: 36000000}
来源:https://stackoverflow.com/questions/37310274/nodejs-how-to-be-logined-after-closing-browser-using-passport-and-express