Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
NodeJS Signed cookies
/**
* Signed session cookies used for persistence
* @param {[type]} name [description]
* @return {[type]} [description]
*/
module.exports = function(name) {
return function(req, res, next) {
req.session = req.signedCookies[name] || {};
res.on('header', function() {
res.cookie(name, req.session, { signed: true });
});
next();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.