[PR #7608] Issue 7607 investigation #24339

Open
opened 2026-04-15 22:19:02 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7608
Author: @Bekacru
Created: 1/25/2026
Status: 🔄 Open

Base: mainHead: cursor/issue-7607-investigation-e146


📝 Commits (2)

  • fa30371 fix(session): regenerate session_data cookie when dontRememberMe is true
  • bc91f39 test: add test verifying twoFactor works without cookieCache

📊 Changes

2 files changed (+248 additions, -0 deletions)

View changed files

📝 packages/better-auth/src/api/routes/session.ts (+2 -0)
packages/better-auth/src/api/routes/session_data_regeneration.test.ts (+246 -0)

📄 Description

Fix session_data cookie regeneration when dontRememberMe or disableRefresh is true.

Previously, setCookieCache was skipped when dontRememberMe or disableRefresh was true, preventing the session_data cookie from being re-sent after expiry. This was incorrect as setCookieCache is for caching session data to avoid DB lookups, not for controlling session lifetime, and should always be called when enabled.


Slack Thread

Open in Cursor Open in Web


Summary by cubic

Regenerates the session_data cookie after it expires even when remember-me is off or refresh is disabled, so sessions keep working and DB lookups are avoided. Addresses #7607.

  • Bug Fixes
    • Always call setCookieCache in getSession when dontRememberMe or disableRefresh are set, refreshing the cookie cache (caching only, not session lifetime).
    • Tests: reissue session_data when missing but session_token is valid (incl. dontRememberMe), and confirm twoFactor TOTP works with cookieCache disabled.

Written for commit bc91f3972e. Summary will update on new commits.


🔄 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/7608 **Author:** [@Bekacru](https://github.com/Bekacru) **Created:** 1/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `cursor/issue-7607-investigation-e146` --- ### 📝 Commits (2) - [`fa30371`](https://github.com/better-auth/better-auth/commit/fa30371bf99742db648ed6e344015b1994b67300) fix(session): regenerate session_data cookie when dontRememberMe is true - [`bc91f39`](https://github.com/better-auth/better-auth/commit/bc91f3972e4d9437923fb869b90567baf7ca615b) test: add test verifying twoFactor works without cookieCache ### 📊 Changes **2 files changed** (+248 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/routes/session.ts` (+2 -0) ➕ `packages/better-auth/src/api/routes/session_data_regeneration.test.ts` (+246 -0) </details> ### 📄 Description Fix `session_data` cookie regeneration when `dontRememberMe` or `disableRefresh` is true. Previously, `setCookieCache` was skipped when `dontRememberMe` or `disableRefresh` was true, preventing the `session_data` cookie from being re-sent after expiry. This was incorrect as `setCookieCache` is for caching session data to avoid DB lookups, not for controlling session lifetime, and should always be called when enabled. --- [Slack Thread](https://betterauth.slack.com/archives/C0A8B5BARUK/p1769370518124229?thread_ts=1769370518.124229&cid=C0A8B5BARUK) <a href="https://cursor.com/background-agent?bcId=bc-7591e3af-ead6-4a02-a8b6-56982536e44d"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/open-in-cursor-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/open-in-cursor-light.svg"><img alt="Open in Cursor" src="https://cursor.com/open-in-cursor.svg"></picture></a>&nbsp;<a href="https://cursor.com/agents?id=bc-7591e3af-ead6-4a02-a8b6-56982536e44d"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/open-in-web-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/open-in-web-light.svg"><img alt="Open in Web" src="https://cursor.com/open-in-web.svg"></picture></a> <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Regenerates the session_data cookie after it expires even when remember-me is off or refresh is disabled, so sessions keep working and DB lookups are avoided. Addresses #7607. - **Bug Fixes** - Always call setCookieCache in getSession when dontRememberMe or disableRefresh are set, refreshing the cookie cache (caching only, not session lifetime). - Tests: reissue session_data when missing but session_token is valid (incl. dontRememberMe), and confirm twoFactor TOTP works with cookieCache disabled. <sup>Written for commit bc91f3972e4d9437923fb869b90567baf7ca615b. Summary will update on new commits.</sup> <!-- 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-04-15 22:19:02 -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#24339