Skip to content

Instantly share code, notes, and snippets.

@Sysetup
Last active November 3, 2017 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sysetup/41c687caad5bc63b0ec123b1f31a7bb5 to your computer and use it in GitHub Desktop.
Save Sysetup/41c687caad5bc63b0ec123b1f31a7bb5 to your computer and use it in GitHub Desktop.
Middleware example. ExpressJS.
app.use(getHost, sessionset);
sessionset({
secret: 'sysetup-x',
resave: false,
saveUninitialized: false,
name: 'session-x',
cookie: {
domain: host //var host; //Store hostname get with getHost function.
}
})
/**
* Middleware function to get local domain.
*/
var getHost = function (req, res, next) {
host = req.get('host');
next();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment