❓ Help with better-auth: cookieCache not persisting after maxAge expires

Hey everyone, I'm using better-auth and I have cookieCache enabled (true) with maxAge set to 60 * 1 (1 minute). When I first log in, two cookies are set:

better-auth.session_token

better-auth.session_data

When I call the API route api/auth/get-session, the session is correctly read from the cookie, and no DB query is made (confirmed using Drizzle's query logger in the console).

However, after maxAge expires:

The better-auth.session_data cookie is destroyed.

A DB query is made to fetch session data (which is expected).

But the session_data cookie is not re-set, so on every subsequent request, it keeps querying the DB again and again.

Is this a bug in better-auth? Or am I missing something in the setup?

Would appreciate any help or clarification on this! 🙏

Would you like me to help you debug this behavior or write a GitHub issue template for it as well?
Was this page helpful?