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

Session object is updated directly and set in response #117

Closed
ajcrites opened this issue Jan 10, 2017 · 1 comment
Closed

Session object is updated directly and set in response #117

ajcrites opened this issue Jan 10, 2017 · 1 comment

Comments

@ajcrites
Copy link
Collaborator

Currently session attributes are set when the response is prepared. When you get the session either with req.session('key') or req.getSession you get the session object back and modifying object properties on it will update the session in the response, e.g.

const sesh = req.getSession();
const objProp = sesh.get('objProp');
objProp.existingProp = "new value";

This will set the session.objProp.existingProp to "new value" in the response even if it was not before.

My suggestion to fix this is to have session.get return a deep copy of the value. You will have to explicitly session.set in order to update the value.

@dblock
Copy link
Collaborator

dblock commented Jan 10, 2017

This is reasonable. Feel free to PR this.

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

No branches or pull requests

2 participants