Skip to content

fix: restrict session deletion to negative MaxAge values - #93

Merged
appleboy merged 2 commits into
masterfrom
cookie
Jan 14, 2026
Merged

fix: restrict session deletion to negative MaxAge values#93
appleboy merged 2 commits into
masterfrom
cookie

Conversation

@appleboy

@appleboy appleboy commented Jan 14, 2026

Copy link
Copy Markdown
Collaborator
  • Only allow session deletion if MaxAge is negative, not zero

fixed #53
fixed #55

- Only allow session deletion if MaxAge is negative, not zero

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Copilot AI review requested due to automatic review settings January 14, 2026 06:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where session cookies with MaxAge = 0 were incorrectly being deleted instead of being treated as browser session cookies. The fix changes the condition from <= 0 to < 0, ensuring only sessions explicitly marked for deletion (MaxAge < 0) are removed.

Changes:

  • Updated the condition in the Save method to only delete sessions when MaxAge < 0 instead of MaxAge <= 0

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread redistore.go
- Add regression test to verify session cookies (MaxAge=0) are created without Max-Age attribute and saved to Redis with the default TTL
- Ensure session retrieval from Redis preserves values for session cookies
- Confirm that setting MaxAge to -1 deletes the session from Redis

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
@appleboy
appleboy merged commit 5865aa7 into master Jan 14, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Problem with session (MaxAge == 0) cookie

2 participants