Skip to content

Clearing and/or revoking session using bun:sqlite database #14

Answered by jcs224
DistantMe asked this question in Q&A
Discussion options

You must be logged in to vote

Old sessions aren't automatically purged, but the expiration is attached to the _expire property of the session JSON object stored in the database. With this, you could write a script or cron job to loop through the sessions table and delete sessions that haven't been used for a while.

If the user tries to access an expired session, it will delete the old session and create a fresh new one. However, if the cookie has been set with a Max-Age or Expires attribute that is ahead of the session expireInSeconds property, the old session will become stale and will have to be cleaned up such as with the method above.

At some point, I might write some docs on how to do this with various databases.…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@DistantMe
Comment options

Answer selected by DistantMe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants