NodeJS | How to be logined after closing browser using passport and express?

自作多情 提交于 2020-01-17 06:00:52

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!