Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Express-session #1012

Open
khushigupta515 opened this issue Jan 7, 2025 · 0 comments
Open

Express-session #1012

khushigupta515 opened this issue Jan 7, 2025 · 0 comments
Labels

Comments

@khushigupta515
Copy link

on extension to #452

1)Want to manually extend session - if user wants to
2)have set rolling to false
3)before expiration updated maxage

extendSession: (req, res) => {
if (!req.session) {
return res.sendStatus(401); // Unauthorized
}
const sessionExtension = 1000 * 60 * 3;
logger.debug('Before extension:', req.session.cookie);
req.session.cookie.maxAge = sessionExtension;
req.session.touch();
req.session.save(err => {
if (err) {
console.log("error in extension", err);
return res.status(500).send('Error extending session.');
}

        const newExpiry = req.session.cookie.expires ? req.session.cookie.expires.getTime() : Date.now() + sessionExtension;
        logger.debug('After extension:', req.session.cookie);
        res.json({ message: 'Session extended by 24 hours.', newExpiry });
    });
},

Still not able to get set-cookie response in the header

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant