Skip to content

Express-session #1012

@khushigupta515

Description

@khushigupta515

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy