Node.js/Express.js session management cookie to be session cookie

旧巷老猫 提交于 2019-12-18 05:55:52

问题


How can I make the connect.sid cookie itself only a session cookie instead of a persistent one?

I unsuccessfully tried

app.use(express.session({cookie: { path: '/', httpOnly: true}, secret:'eeuqram'}));

But the cookie still had the expiration timestamp.


回答1:


 app.use(express.session({cookie: { path: '/', httpOnly: true, maxAge: null}, secret:'eeuqram'}));

The above worked. So by setting maxAge to be null, I did manage expressjs to use session cookies. Phew.



来源:https://stackoverflow.com/questions/8842389/node-js-express-js-session-management-cookie-to-be-session-cookie

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