Skip to content

Commit

Permalink
fix(regenerate) flush argument and missing session id (#144)
Browse files Browse the repository at this point in the history
### 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.
  • Loading branch information
bungle authored Jan 14, 2022
1 parent 33393db commit 41991f8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 10 additions & 1 deletion lib/resty/session.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 41991f8

Please sign in to comment.