[GH-ISSUE #3117] Support caching of modified session data with customSession plugin #9478

Closed
opened 2026-04-13 04:57:30 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @arthberman on GitHub (Jun 21, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/3117

Is this suited for github?

  • Yes, this is suited for github

I'm frustrated that when using the customSession plugin to add custom fields to the session data, the session caching mechanism in Better Auth no longer works. This means that any custom data added to the session cannot be accessed through getSessionCookie or auth.api.getSession, which limits the flexibility and performance benefits of session caching.

Describe the solution you'd like

I would like Better Auth to support session caching even when the customSession plugin is used to modify or extend the session data. Ideally, it should be possible to add custom fields to the session, have them cached, and access them through the standard session retrieval methods.

Describe alternatives you've considered

I've considered not using the customSession plugin and only relying on the default session fields, but this does not meet my application's requirements for storing additional user-specific or context-specific data. Another alternative is to manage custom data outside of the session, but this adds unnecessary complexity and overhead.

Additional context

This limitation was discussed in the Better Auth Discord, where it was confirmed that session caching does not currently work with custom session data. Having this feature would greatly improve developer experience and enable more advanced use cases.

Originally created by @arthberman on GitHub (Jun 21, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/3117 ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. I'm frustrated that when using the customSession plugin to add custom fields to the session data, the session caching mechanism in Better Auth no longer works. This means that any custom data added to the session cannot be accessed through getSessionCookie or auth.api.getSession, which limits the flexibility and performance benefits of session caching. ### Describe the solution you'd like I would like Better Auth to support session caching even when the customSession plugin is used to modify or extend the session data. Ideally, it should be possible to add custom fields to the session, have them cached, and access them through the standard session retrieval methods. ### Describe alternatives you've considered I've considered not using the customSession plugin and only relying on the default session fields, but this does not meet my application's requirements for storing additional user-specific or context-specific data. Another alternative is to manage custom data outside of the session, but this adds unnecessary complexity and overhead. ### Additional context This limitation was discussed in the Better Auth [Discord](https://discord.com/channels/1288403910284935179/1385189982813159507), where it was confirmed that session caching does not currently work with custom session data. Having this feature would greatly improve developer experience and enable more advanced use cases.
GiteaMirror added the enhancementlocked labels 2026-04-13 04:57:30 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Sep 20, 2025):

Hi, @arthberman. I'm Dosu, and I'm helping the better-auth team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You requested support for caching modified session data when using the customSession plugin.
  • Currently, custom session fields are not cached or accessible via standard methods.
  • This limitation affects flexibility and performance, requiring developers to manage custom data outside sessions.
  • Enabling caching for custom session data would improve developer experience and enable advanced use cases.
  • There has been no activity or comments on this issue so far.

Next Steps:

  • Please let me know if this issue is still relevant with the latest version of better-auth by commenting below.
  • If I do not hear back within 7 days, I will automatically close this issue.

Thank you for your understanding and contribution!

<!-- gh-comment-id:3315072698 --> @dosubot[bot] commented on GitHub (Sep 20, 2025): Hi, @arthberman. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog and am marking this issue as stale. **Issue Summary:** - You requested support for caching modified session data when using the customSession plugin. - Currently, custom session fields are not cached or accessible via standard methods. - This limitation affects flexibility and performance, requiring developers to manage custom data outside sessions. - Enabling caching for custom session data would improve developer experience and enable advanced use cases. - There has been no activity or comments on this issue so far. **Next Steps:** - Please let me know if this issue is still relevant with the latest version of better-auth by commenting below. - If I do not hear back within 7 days, I will automatically close this issue. Thank you for your understanding and contribution!
Author
Owner

@kevinehosford commented on GitHub (Sep 30, 2025):

I still see this issue and it is kind of frustrating behavior.

<!-- gh-comment-id:3353869393 --> @kevinehosford commented on GitHub (Sep 30, 2025): I still see this issue and it is kind of frustrating behavior.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#9478