Skip to content

Instantly share code, notes, and snippets.

@charliewilco
Last active September 15, 2018 22:31
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 charliewilco/a426d2431db39d093bff5827baa8cbfd to your computer and use it in GitHub Desktop.
Save charliewilco/a426d2431db39d093bff5827baa8cbfd to your computer and use it in GitHub Desktop.
function NodeCookieParser(req) {
let cookies = {};
req.headers.cookie &&
req.headers.cookie.split(";").forEach(function(cookie) {
let parts = cookie.split("=");
cookies[parts[0].trim()] = (parts[1] || "").trim();
});
return cookies
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment