[PR #4558] [MERGED] fix: make cookie cache respect dontRememberMe mode #5446

Closed
opened 2026-03-13 12:23:06 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4558
Author: @frectonz
Created: 9/10/2025
Status: Merged
Merged: 9/11/2025
Merged by: @himself65

Base: canaryHead: fix/cookie-cache-in-dont-remember-mode


📝 Commits (2)

  • 4046a2d test(cookies): cookie cache with dontRememberMe
  • 32bf54f feat(cookies): make session_data cookie respect dontRememberMe

📊 Changes

3 files changed (+50 additions, -11 deletions)

View changed files

📝 packages/better-auth/src/api/routes/session.ts (+1 -1)
📝 packages/better-auth/src/cookies/cookies.test.ts (+36 -0)
📝 packages/better-auth/src/cookies/index.ts (+13 -10)

📄 Description

closes #4491


Summary by cubic

Make the cookie cache respect dontRememberMe. When a user opts out of “remember me”, the session_data cookie is now session-only (no max-age) and won’t persist after the browser closes.

  • Bug Fixes

    • Propagate dontRememberMe to setCookieCache in getSession and setSessionCookie.
    • In setCookieCache, omit maxAge when dontRememberMe is true and set the cookie with updated options.
    • Add tests to verify session_token and session_data cookies have no max-age in dontRememberMe mode.
  • Migration

    • If you call setCookieCache directly, update calls to: setCookieCache(ctx, session, dontRememberMe).

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/4558 **Author:** [@frectonz](https://github.com/frectonz) **Created:** 9/10/2025 **Status:** ✅ Merged **Merged:** 9/11/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/cookie-cache-in-dont-remember-mode` --- ### 📝 Commits (2) - [`4046a2d`](https://github.com/better-auth/better-auth/commit/4046a2dc62e7d5ae8e3c2896340d028fb3663384) test(cookies): cookie cache with `dontRememberMe` - [`32bf54f`](https://github.com/better-auth/better-auth/commit/32bf54f5d8e9b80359748fb772e2c0eb5ea72909) feat(cookies): make `session_data` cookie respect `dontRememberMe` ### 📊 Changes **3 files changed** (+50 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/routes/session.ts` (+1 -1) 📝 `packages/better-auth/src/cookies/cookies.test.ts` (+36 -0) 📝 `packages/better-auth/src/cookies/index.ts` (+13 -10) </details> ### 📄 Description closes #4491 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Make the cookie cache respect dontRememberMe. When a user opts out of “remember me”, the session_data cookie is now session-only (no max-age) and won’t persist after the browser closes. - **Bug Fixes** - Propagate dontRememberMe to setCookieCache in getSession and setSessionCookie. - In setCookieCache, omit maxAge when dontRememberMe is true and set the cookie with updated options. - Add tests to verify session_token and session_data cookies have no max-age in dontRememberMe mode. - **Migration** - If you call setCookieCache directly, update calls to: setCookieCache(ctx, session, dontRememberMe). <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 12:23:06 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#5446