Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

express js session is serialized incorrectly

express js session is serialized incorrectly


I use node.js and expressexpress. I add a dictionary to the req.session. It appears that the value inside the dictionary does not saved ()between cleints calls)

I will really appreciate any solution.

'req.session.test = [];
'req.session.test["obj1"] = obj; // Does not save in the session! - disappears between client calls'
'req.session.test.push(obj);     // saved in the session and can be found between client calls'

Thanks in advance, Shai

Problem courtesy of: user1798168


You cannot add objects to an array like that. If you want named keys (a "hash") then you'll have to use an object. Try

req.session.test = {};
req.session.test["obj1"] = obj;
Solution courtesy of: Max


View additional discussion.

This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

express js session is serialized incorrectly


Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription