node.js - ExpressJS Session Cookies Edited Via Post Don't Save -
i'm quite confused here. can edit , read cookies whenever there request, if edit cookie via post, not save:
// exports.index = function(req, res) { req.session.teststore = "this set get"; console.log('reading cookie..... :::' , req.session.teststore); res.render('index'); }; // outputs: 'reading cookie..... ::: , 'this set get' exports.page2 = function(req, res) { console.log('reading cookie..... :::' , req.session.teststore); res.render('page2'); res.end(); }; // outputs: 'reading cookie..... ::: , 'this set get' //post exports.update = function (req,res) { console.log('the value of cookie ::: ' , req.session.teststore); req.session.teststore = "this set post"; console.log('the value of cookie ::: ' , req.session.teststore);}; res.send(200); } // outputs: value of cookie ::: set value of cookie ::: set post //get exports.page3 = function(req, res) { console.log('reading cookie..... :::' , req.session.teststore); res.render('page3'); res.end(); }; // outputs: 'reading cookie..... ::: , 'this set get'
i'm confused because expect request page 3 see cookie updated. confirm, cookie set once in '/' index request , altered in post request.
any ideas?
Comments
Post a Comment