Node.js (express) when saving instances of the class in req.session lost methods, why?

var Cart = function() {
this.sum = 1;


this.add = function(){ this.sum++; };
}

req.session.cart = new Cart();

when repeated calls to sum have, and add no. How can I save an object with methods?
June 14th 19 at 18:17
0 answer

Find more questions by tags Node.jsSessions