From 4cb215c951cefe60099383a6bef2a0020594e636 Mon Sep 17 00:00:00 2001 From: nbkhope Date: Sun, 19 Mar 2023 02:18:17 -0400 Subject: [PATCH] Don't automatically add Expires in res.cookie if expires option is explicitly set to 0 --- lib/response.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/response.js b/lib/response.js index fede486c06..3bc8f04cc4 100644 --- a/lib/response.js +++ b/lib/response.js @@ -872,7 +872,9 @@ res.cookie = function (name, value, options) { var maxAge = opts.maxAge - 0 if (!isNaN(maxAge)) { - opts.expires = new Date(Date.now() + maxAge) + if (opts.expires !== 0) { + opts.expires = new Date(Date.now() + maxAge) + } opts.maxAge = Math.floor(maxAge / 1000) } }