rsnext/examples/with-firebase-authentication/utils/middleware/cookieSessionRefresh.js

10 lines
372 B
JavaScript
Raw Normal View History

// Update a value in the cookie so that the set-cookie will be sent.
// Only changes every minute so that it's not sent with every request.
// https://github.com/expressjs/cookie-session#extending-the-session-expiration
2020-05-18 21:24:37 +02:00
export default (handler) => (req, res) => {
if (req.session) {
req.session.nowInMinutes = Math.floor(Date.now() / 60e3)
}
handler(req, res)
}