Skip to content

Add option to preserve session data when calling regenerate() #1036

@nariakiraHara

Description

@nariakiraHara

Currently, req.session.regenerate() creates a new session and destroys the previous one, including its data.

In some use cases, developers may want to change only the session ID for security reasons (such as preventing session fixation) but keep the existing session data.

I would like to propose adding an option to the regenerate() method to preserve the current session data.

req.session.regenerate({ preserveData: true });

If preserveData: true, the session data from the old session would be copied to the new session.

If omitted or false, the behavior remains unchanged.

This would allow more flexible session management without breaking existing functionality.

If the maintainers agree with this idea, I am happy to work on a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No 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