Hi
My express-session code like this.
I set resave: true to let session be restored whenever there is a api call from client,but I find that the cookie in the browser is not modified with the session.
Is there a built-in mode or a proper way to modify the cookie expire time?
session({
secret: "xxxx",
cookie: {
domain: ".yy.com",
httpOnly: true,
maxAge: 1000 * 60 * 60
},
resave: true,
saveUninitialized: false,
store: new MongoStore({
url: "xxx--mongo-xxx.url",
mongoOptions: { useUnifiedTopology: true }
})
})
@HelloKevinTian Setting rolling to true will reset the cookie maxAge to original maxAge every time client requests.
Let me know if it helps to resolve your issue.
@HelloKevinTian Setting
rollingtotruewill reset the cookie maxAge to original maxAge every time client requests.
Let me know if it helps to resolve your issue.
Thanks, It's working well.
Here is my code:
session({
secret: "xxxx",
cookie: {
domain: ".yy.com",
httpOnly: true,
maxAge: 1000 * 60 * 60
},
resave: true,
saveUninitialized: false,
rolling:true,
store: new MongoStore({
url: "xxx--mongo-xxx.url",
mongoOptions: { useUnifiedTopology: true }
})
})
Most helpful comment
Thanks, It's working well.
Here is my code: