From 41991f8bbe887c5988613e018653d40458c3c808 Mon Sep 17 00:00:00 2001 From: Aapo Talvensaari Date: Fri, 14 Jan 2022 20:14:44 +0200 Subject: [PATCH] fix(regenerate) flush argument and missing session id (#144) ### Summary 3.9 release introduces a small bug where the session:regenerate flush parameter was not taken in account. I also added automatic id generation just in case, if it is missing for some reason. --- Changes.md | 6 ++++++ lib/resty/session.lua | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Changes.md b/Changes.md index 08ce191b..564bf79d 100644 --- a/Changes.md +++ b/Changes.md @@ -2,6 +2,12 @@ All notable changes to `lua-resty-session` will be documented in this file. +## [3.10] - 2022-01-14 +### Fixed +- 3.9 introduced an issue where calling session:regenerate with flush=true, + didn't really flush if the session strategy was `regenerate`. + + ## [3.9] - 2022-01-14 ### Fixed - Fix #138 issue of chunked cookies are not expired when session shrinks, diff --git a/lib/resty/session.lua b/lib/resty/session.lua index be60c2ee..83dbdf8a 100644 --- a/lib/resty/session.lua +++ b/lib/resty/session.lua @@ -684,9 +684,18 @@ end function session:regenerate(flush, close) close = close ~= false - if not self.strategy.regenerate then + if self.strategy.regenerate then + if flush then + self.data = {} + end + + if not self.id then + self.id = session:identifier() + end + else regenerate(self, flush) end + return save(self, close) end