[PR #5645] [MERGED] feat: session store chunking #6136

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5645
Author: @himself65
Created: 10/28/2025
Status: Merged
Merged: 10/29/2025
Merged by: @himself65

Base: canaryHead: himself65/2025/10/28/session-store


📝 Commits (9)

  • 80fbe2d feat: session store
  • f1df2cf Update packages/better-auth/src/cookies/cookies.test.ts
  • 14aea21 Update packages/better-auth/src/cookies/cookies.test.ts
  • 8fdab8b Update packages/better-auth/src/cookies/cookies.test.ts
  • 4611cfd Update packages/better-auth/src/cookies/cookies.test.ts
  • d29264e fix: move files
  • f41b4b1 fix: type
  • 9f18edc fix: cache
  • 16de209 fix: refactor code

📊 Changes

4 files changed (+638 additions, -57 deletions)

View changed files

📝 packages/better-auth/src/api/routes/session.ts (+5 -24)
📝 packages/better-auth/src/cookies/cookies.test.ts (+288 -24)
📝 packages/better-auth/src/cookies/index.ts (+57 -9)
packages/better-auth/src/cookies/session-store.ts (+288 -0)

📄 Description

Summary by cubic

Add cookie chunking for session data to support values larger than 4KB and prevent cache failures. Session cookies are split, reassembled on read, and fully cleaned up on sign out.

  • New Features
    • Introduced createSessionStore to chunk large session cookies and set all parts; exported for reuse.
    • setCookieCache now uses the session store; deleteSessionCookie removes all session_data chunks.
    • getCookieCache and the session route reconstruct session_data from chunked cookies if needed.
    • Added tests for chunking, reconstruction, and cleanup.

🔄 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/5645 **Author:** [@himself65](https://github.com/himself65) **Created:** 10/28/2025 **Status:** ✅ Merged **Merged:** 10/29/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2025/10/28/session-store` --- ### 📝 Commits (9) - [`80fbe2d`](https://github.com/better-auth/better-auth/commit/80fbe2deee0f77618bb59967179fc27cedbc24bb) feat: session store - [`f1df2cf`](https://github.com/better-auth/better-auth/commit/f1df2cf14b4790adcec41fe2f28ad18657bb0929) Update packages/better-auth/src/cookies/cookies.test.ts - [`14aea21`](https://github.com/better-auth/better-auth/commit/14aea21f81584f74739c17b3f367390f05467101) Update packages/better-auth/src/cookies/cookies.test.ts - [`8fdab8b`](https://github.com/better-auth/better-auth/commit/8fdab8b499afc40e3862c895e7089a435fdb7b08) Update packages/better-auth/src/cookies/cookies.test.ts - [`4611cfd`](https://github.com/better-auth/better-auth/commit/4611cfdfc8cf087e956fcf84cf52840e8f4b5fa4) Update packages/better-auth/src/cookies/cookies.test.ts - [`d29264e`](https://github.com/better-auth/better-auth/commit/d29264ea15a0926dab0e04e0d93569f43a6e2af2) fix: move files - [`f41b4b1`](https://github.com/better-auth/better-auth/commit/f41b4b1fe4378f1449b17f5f55890ae4b6299bf5) fix: type - [`9f18edc`](https://github.com/better-auth/better-auth/commit/9f18edc9609f28a2407019f0797630856865883f) fix: cache - [`16de209`](https://github.com/better-auth/better-auth/commit/16de2096ebf7bba26f1adaf3aef29397adf5fe34) fix: refactor code ### 📊 Changes **4 files changed** (+638 additions, -57 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/routes/session.ts` (+5 -24) 📝 `packages/better-auth/src/cookies/cookies.test.ts` (+288 -24) 📝 `packages/better-auth/src/cookies/index.ts` (+57 -9) ➕ `packages/better-auth/src/cookies/session-store.ts` (+288 -0) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Add cookie chunking for session data to support values larger than 4KB and prevent cache failures. Session cookies are split, reassembled on read, and fully cleaned up on sign out. - **New Features** - Introduced createSessionStore to chunk large session cookies and set all parts; exported for reuse. - setCookieCache now uses the session store; deleteSessionCookie removes all session_data chunks. - getCookieCache and the session route reconstruct session_data from chunked cookies if needed. - Added tests for chunking, reconstruction, and cleanup. <!-- 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:48:58 -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#6136