node.js - How do I keep a session variable from changing? -


so i've got session variable, req.session.user, contains object corresponding user account. when this,

var user = req.session.user; var fakeuser = user; fakeuser.username = 'bob'; 

user.username , req.session.user.username both changed 'bob' well. how prevent this?

clone

function clone(obj) {     if (null == obj || "object" != typeof obj) return obj;     var copy = obj.constructor();     (var attr in obj) {         if (obj.hasownproperty(attr)) copy[attr] = obj[attr];     }     return copy; } 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -