[GH-ISSUE #6893] Even if the cookieCache is configured and the authClient.revokeOtherSessions() is called, the session will only become invalid when the cache expires. #27989

Closed
opened 2026-04-17 19:18:39 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @tech-zjf on GitHub (Dec 20, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/6893

Originally assigned to: @bytaesu on GitHub.

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Multi-device login to the same account
  2. When one of the devices successfully logged in after resetting the password, the following code was executed: authClient.revokeOtherSessions()
  3. The database only has one piece of data for the current user's session. This is normal.
    4.However, the other device was still in a logged-in state. After my test, I found that it would only expire after 5 minutes, with the configuration being cookieCache: {enabled:true, maxAge: 5 * 60,}. This is not the result I was expecting.

Current vs. Expected behavior

After calling authClient.revokeOtherSessions(), the sessions of other devices remain valid within the cache period.

What version of Better Auth are you using?

1.3.14

System info

"better-auth": "^1.3.14",

Which area(s) are affected? (Select all that apply)

Client

Auth config (if applicable)

await authClient.revokeOtherSessions();

  session: {
    cookieCache: {
      enabled: false,
      maxAge: 5 * 60, // Cache duration in seconds
    },
  },

Additional context

No response

Originally created by @tech-zjf on GitHub (Dec 20, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/6893 Originally assigned to: @bytaesu on GitHub. ### Is this suited for github? - [ ] Yes, this is suited for github ### To Reproduce 1. Multi-device login to the same account 2. When one of the devices successfully logged in after resetting the password, the following code was executed: authClient.revokeOtherSessions() 3. The database only has one piece of data for the current user's session. This is normal. 4.However, the other device was still in a logged-in state. After my test, I found that it would only expire after 5 minutes, with the configuration being cookieCache: {enabled:true, maxAge: 5 * 60,}. This is not the result I was expecting. ### Current vs. Expected behavior After calling `authClient.revokeOtherSessions()`, the sessions of other devices remain valid within the cache period. ### What version of Better Auth are you using? 1.3.14 ### System info ```bash "better-auth": "^1.3.14", ``` ### Which area(s) are affected? (Select all that apply) Client ### Auth config (if applicable) ```typescript await authClient.revokeOtherSessions(); session: { cookieCache: { enabled: false, maxAge: 5 * 60, // Cache duration in seconds }, }, ``` ### Additional context _No response_
GiteaMirror added the locked label 2026-04-17 19:18:39 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Dec 20, 2025):

It appears you're experiencing an issue where calling authClient.revokeOtherSessions() does not immediately invalidate sessions on other devices, which remain active until the cache expires. This behavior is noted in the documentation, and it indicates that even when sessions are revoked, any active sessions might still exist until the cache configured by cookieCache expires.

To troubleshoot this further, ensure that your cookieCache configuration is set appropriately and consider the following steps:

  1. Check your cookieCache settings: Make sure that the configuration is correct, as you are currently seeing a session expiry due to the cache timing. You might want to explore reducing the maxAge to achieve quicker invalidation.

  2. Review Multi-Session implementations: There are discussions about using server-side session management for multi-device sessions, which might offer enhanced control and quicker revocation of active sessions. Depending on your application’s structure, consider implementing server-bound sessions if that is feasible for you.

  3. Open issues: There are existing issues related to session revocation not behaving as expected, and they may provide further insights. Look into the open issues in the repository or engage with the Better Auth community for additional support.

  4. Feedback and Enhancement Requests: If this behavior does not align with your application requirements, consider creating or contributing to an enhancement request where this behavior can be improved upon in future releases.

Feel free to reach out if you have further questions or need assistance on specific areas! Would you like to explore how to implement server-side sessions or discuss more about the multiSession plugin?

If you need more help, tag @better-auth-agent in a comment so I can respond.

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3677261325 --> @better-auth-agent[bot] commented on GitHub (Dec 20, 2025): It appears you're experiencing an issue where calling `authClient.revokeOtherSessions()` does not immediately invalidate sessions on other devices, which remain active until the cache expires. This behavior is noted in the documentation, and it indicates that even when sessions are revoked, any active sessions might still exist until the cache configured by `cookieCache` expires. To troubleshoot this further, ensure that your `cookieCache` configuration is set appropriately and consider the following steps: 1. **Check your `cookieCache` settings:** Make sure that the configuration is correct, as you are currently seeing a session expiry due to the cache timing. You might want to explore reducing the `maxAge` to achieve quicker invalidation. 2. **Review Multi-Session implementations:** There are discussions about using server-side session management for multi-device sessions, which might offer enhanced control and quicker revocation of active sessions. Depending on your application’s structure, consider implementing server-bound sessions if that is feasible for you. 3. **Open issues:** There are existing issues related to session revocation not behaving as expected, and they may provide further insights. Look into the open issues in the repository or engage with the Better Auth community for additional support. 4. **Feedback and Enhancement Requests:** If this behavior does not align with your application requirements, consider creating or contributing to an enhancement request where this behavior can be improved upon in future releases. Feel free to reach out if you have further questions or need assistance on specific areas! Would you like to explore how to implement server-side sessions or discuss more about the `multiSession` plugin? _If you need more help, tag @better-auth-agent in a comment so I can respond._ <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) • [Discord](https://discord.gg/fG2XXEuQX3) • [GitHub](https://github.com/Skyvern-AI/Skyvern) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/fG2XXEuQX3) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/Skyvern-AI/Skyvern)
Author
Owner

@bytaesu commented on GitHub (Dec 23, 2025):

Hi @tech-zjf,

Cookie caching exists for performance, so you need to balance security and performance. I've added a note about this 🙂

Image
<!-- gh-comment-id:3688083680 --> @bytaesu commented on GitHub (Dec 23, 2025): Hi @tech-zjf, Cookie caching exists for performance, so you need to balance security and performance. I've added a note about this 🙂 <img width="489" height="415" alt="Image" src="https://github.com/user-attachments/assets/b742d5e7-c472-4bb5-a269-350964b2e293" />
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#27989