Add configuration option to mark sessions as inactive instead of deleting them #1882

Closed
opened 2026-03-13 09:10:30 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @Joseevb on GitHub (Sep 8, 2025).

Is this suited for github?

  • Yes, this is suited for github

Currently, when signing out via the default methods, the session entry in the database gets deleted. This makes it hard to keep a log of the sessions that have existed in the application.

Describe the solution you'd like

I would like for a configuration option to exist that allowed an active boolean column to exist in the session table, with the optional ability to make it a timestamp value instead, such as invalidatedAt.

Describe alternatives you've considered

This would look something like this:

const auth = betterAuth({
  // database configuration
  session: {
    deleteSessionOnSignOut: {
      enabled: false // by default, true
      timestamp: false // whether or not the field is a boolean or a timestamp
    }
  }
})

This would then add the field in the generated table schema, and when signing out, for example via:

authClient.signOut();

Then the session would be kept in the database, but marked as inactive.

Additional context

No response

Originally created by @Joseevb on GitHub (Sep 8, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. Currently, when signing out via the default methods, the session entry in the database gets deleted. This makes it hard to keep a log of the sessions that have existed in the application. ### Describe the solution you'd like I would like for a configuration option to exist that allowed an `active` boolean column to exist in the session table, with the optional ability to make it a timestamp value instead, such as `invalidatedAt`. ### Describe alternatives you've considered This would look something like this: ```typescript const auth = betterAuth({ // database configuration session: { deleteSessionOnSignOut: { enabled: false // by default, true timestamp: false // whether or not the field is a boolean or a timestamp } } }) ``` This would then add the field in the generated table schema, and when signing out, for example via: ```typescript authClient.signOut(); ``` Then the session would be kept in the database, but marked as inactive. ### Additional context _No response_
GiteaMirror added the enhancement label 2026-03-13 09:10:30 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Dec 8, 2025):

Hi, @Joseevb. 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 a feature to mark sessions as inactive instead of deleting them upon sign-out.
  • Proposed adding an active boolean or invalidatedAt timestamp field in the session table.
  • Suggested configuration options like deleteSessionOnSignOut.enabled to control this behavior.
  • This would allow session history to be retained in the database while marking sessions inactive.
  • There has been no further activity or comments on this issue so far.

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 don’t hear back within 7 days, I will automatically close this issue.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Dec 8, 2025): Hi, @Joseevb. 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 a feature to mark sessions as inactive instead of deleting them upon sign-out. - Proposed adding an `active` boolean or `invalidatedAt` timestamp field in the session table. - Suggested configuration options like `deleteSessionOnSignOut.enabled` to control this behavior. - This would allow session history to be retained in the database while marking sessions inactive. - There has been no further activity or comments on this issue so far. **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 don’t hear back within 7 days, I will automatically close this issue. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1882