From 87235c9ebff79d1f957d0fe6b53e3ab4245ffaba Mon Sep 17 00:00:00 2001 From: kamalyusuf Date: Sat, 21 Sep 2024 15:09:29 +0100 Subject: [PATCH] add skipNextSave flag to skip automatic session save --- index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/index.js b/index.js index d41b2378..19a8a0e7 100644 --- a/index.js +++ b/index.js @@ -452,6 +452,12 @@ function session(options) { return false; } + // skip save if flag is set + if (req.session.skipNextSave) { + delete req.session.skipNextSave; + return false; + } + return !saveUninitializedSession && !savedHash && cookieId !== req.sessionID ? isModified(req.session) : !isSaved(req.session)