Modifying the session or the user should invalidate active session #1380

Closed
opened 2026-03-13 08:35:56 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @xn1cklas on GitHub (Jun 18, 2025).

Is this suited for github?

  • Yes, this is suited for github

When modifying the user or the session it‘s crucial to refresh the cookies to make sure the changed values are available via the better auth server api.

Describe the solution you'd like

Interacting with the better auth api should revalidate the active session cookie.

Describe alternatives you've considered

Manually revalidating the session cookie

Additional context

No response

Originally created by @xn1cklas on GitHub (Jun 18, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. When modifying the user or the session it‘s crucial to refresh the cookies to make sure the changed values are available via the better auth server api. ### Describe the solution you'd like Interacting with the better auth api should revalidate the active session cookie. ### Describe alternatives you've considered Manually revalidating the session cookie ### Additional context _No response_
GiteaMirror added the enhancement label 2026-03-13 08:35:56 -05:00
Author
Owner

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

Hi, @xn1cklas. 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 suggested enhancing session management by automatically invalidating and refreshing the active session cookie when session or user data changes.
  • This would allow updated values to be immediately reflected in the Better Auth server API.
  • No further comments or activity have occurred on this request since it was opened.
  • The issue remains unresolved with no proposed implementation yet.

Next Steps:

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

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Sep 17, 2025): Hi, @xn1cklas. 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 suggested enhancing session management by automatically invalidating and refreshing the active session cookie when session or user data changes. - This would allow updated values to be immediately reflected in the Better Auth server API. - No further comments or activity have occurred on this request since it was opened. - The issue remains unresolved with no proposed implementation yet. **Next Steps:** - Please let me know if this feature is still relevant to the latest version of better-auth by commenting on this issue. - If I do not hear back within 7 days, the issue will be automatically closed. Thank you for your understanding and contribution!
Author
Owner

@yanickrochon commented on GitHub (Nov 25, 2025):

I stumbled across this problem because I have component on Storybook which rely on the current user session. However I'm trying to test how these component behave with as well as without a user session. When Storybook launches, I can mock the initial fetch so the user session returned is mocked, and it is mocked successfully. But when I load another component who should not have a mocked session, the fetch is never called and the session is not updated.

In short, if I initially load Storybook with a story that's not supposed to have a session, then all components act is if there is not session. If I initially load a Storybook with a story that's supposed to have a session, then all components act as if there is a session. I cannot invalidate the session between components!

@yanickrochon commented on GitHub (Nov 25, 2025): I stumbled across this problem because I have component on Storybook which rely on the current user session. However I'm trying to test how these component behave with as well as without a user session. When Storybook launches, I can mock the initial `fetch` so the user session returned is mocked, and it is mocked successfully. But when I load another component who should not have a mocked session, the `fetch` is never called and the session is not updated. In short, if I initially load Storybook with a story that's not supposed to have a session, then all components act is if there is not session. If I initially load a Storybook with a story that's supposed to have a session, then all components act as if there is a session. I cannot invalidate the session between components!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1380