Sending cookie to Node.js -
i'm making request node.js server using postman plugin chrome. in headers have field called cookie , it's populated authsession cookie so:
authsession="somekeyhere";
i've tried using set-cookie field well, honest don't know difference between two.
here code that's supposed receive cookie, doesn't seem working.
exports.add = function(req, res) { console.log(req.cookies['authsession']); }
it keeps logging undefined. i'm doing wrong, i'm not sure what.
verify first setting cookies working. use function below , load twice. first time it'll show existing cookie. second time it'll show cookie set first time.
exports.add = function(req, res) { console.log(req.cookies['authsession']); res.cookie('authsession', 'somekeyhere'); res.send("<html><body>hello world</body></html>"); }
Comments
Post a Comment