[PR #5412] feat(session): add option to exclude user fields from cookie cache #5992

Open
opened 2026-03-13 12:44:00 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5412
Author: @Blackmamoth
Created: 10/19/2025
Status: 🔄 Open

Base: canaryHead: feat/exclude-user-fields-from-cookie-cache


📝 Commits (4)

  • 58186dd feat(session): add option to exclude user fields from cookie cache
  • eba5149 update docs
  • fbcb408 Merge branch 'canary' into feat/exclude-user-fields-from-cookie-cache
  • 827f261 Merge branch 'canary' into feat/exclude-user-fields-from-cookie-cache

📊 Changes

5 files changed (+75 additions, -3 deletions)

View changed files

📝 docs/content/docs/reference/options.mdx (+3 -2)
📝 packages/better-auth/src/cookies/cookie-utils.ts (+17 -0)
📝 packages/better-auth/src/cookies/cookies.test.ts (+44 -0)
📝 packages/better-auth/src/cookies/index.ts (+6 -1)
📝 packages/core/src/types/init-options.ts (+5 -0)

📄 Description

fixes #5378


Summary by cubic

Adds excludeUserFields to session.cookieCache to skip selected user fields in the cookie cache, reducing size and limiting sensitive data while always keeping user.id for session integrity. Addresses #5378.

  • New Features
    • New option: session.cookieCache.excludeUserFields (default: []).
    • user.id is never excluded; filtering handled via excludeFields helper.
    • Updated types, docs with example, and added tests; minor docs 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/5412 **Author:** [@Blackmamoth](https://github.com/Blackmamoth) **Created:** 10/19/2025 **Status:** 🔄 Open **Base:** `canary` ← **Head:** `feat/exclude-user-fields-from-cookie-cache` --- ### 📝 Commits (4) - [`58186dd`](https://github.com/better-auth/better-auth/commit/58186dd16e05250d353a66fd7378b39c0cb072de) feat(session): add option to exclude user fields from cookie cache - [`eba5149`](https://github.com/better-auth/better-auth/commit/eba51491a270475863be3076d05e8dc0a86916d3) update docs - [`fbcb408`](https://github.com/better-auth/better-auth/commit/fbcb408b8c5721b0eb5b052ff61b348b3dcd47ac) Merge branch 'canary' into feat/exclude-user-fields-from-cookie-cache - [`827f261`](https://github.com/better-auth/better-auth/commit/827f261ea2a7d947c7db468b1f976a4fb39a4738) Merge branch 'canary' into feat/exclude-user-fields-from-cookie-cache ### 📊 Changes **5 files changed** (+75 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/reference/options.mdx` (+3 -2) 📝 `packages/better-auth/src/cookies/cookie-utils.ts` (+17 -0) 📝 `packages/better-auth/src/cookies/cookies.test.ts` (+44 -0) 📝 `packages/better-auth/src/cookies/index.ts` (+6 -1) 📝 `packages/core/src/types/init-options.ts` (+5 -0) </details> ### 📄 Description fixes #5378 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds excludeUserFields to session.cookieCache to skip selected user fields in the cookie cache, reducing size and limiting sensitive data while always keeping user.id for session integrity. Addresses #5378. - New Features - New option: session.cookieCache.excludeUserFields (default: []). - user.id is never excluded; filtering handled via excludeFields helper. - Updated types, docs with example, and added tests; minor docs 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:44:00 -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#5992