#11466·better-auth

setSessionCookie never clears dont_remember: a persistent sign-in after a rememberMe: false session is never refreshed

Author: user2223Created Sep 29, 2026Updated Sep 29, 2026

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

This is the general case behind #10734. #10735 fixes it for stopImpersonating only, by expiring the marker in that route. The same residue comes from any persistent sign-in or sign-up that follows a non-remembered session in the same browser:

  1. Sign in with rememberMe: false. The response sets session_token without Max-Age and sets the signed dont_remember cookie. Both are expected.
  2. Without closing the browser, sign in again, as the same or another user, with rememberMe left at its default true. session_token now has Max-Age, but dont_remember is still in the browser.
  3. Call /get-session after updateAge has passed. The session is not refreshed and expiresAt does not slide, because getSession returns before the refresh branch while dont_remember is present.

The same happens after sign-up, email or username sign-in, and any other route that calls setSessionCookie(ctx, session, false).

Current vs. Expected behavior

Expected: a session the user asked to be remembered is refreshed like any remembered session, whatever an earlier session in the same browser chose.

Current: setSessionCookie sets dont_remember when dontRememberMe is true, but has no branch that expires it when dontRememberMe is explicitly false. In 1.7.6 dist/cookies/index.mjs:

javascript
const maxAge = dontRememberMe ? void 0 : ctx.context.sessionConfig.expiresIn;
await ctx.setSignedCookie(ctx.context.authCookies.sessionToken.name, session.session.token, ...);
if (dontRememberMe) await ctx.setSignedCookie(ctx.context.authCookies.dontRememberToken.name, "true", ...);

getSession (dist/api/routes/session.mjs, if (dontRememberMe || ctx.query?.disableRefresh)) then skips the refresh for the new, persistent session until the browser session ends. With session restore, that can outlast expiresIn, and the session then expires at its creation time plus expiresIn instead of sliding.

Suggested fix: in setSessionCookie, expire dontRememberToken when dontRememberMe === false is passed explicitly. When it is undefined, it is derived from the existing cookie, so keep it as is there. This would also cover the stopImpersonating case that #10735 fixes in the route.

What version of Better Auth are you using?

1.7.5 in production use. Verified unchanged in 1.7.6 (dist/cookies/index.mjs).

Provide environment information

bash
Node 24, Fastify backend using the Node handler. Not environment-specific: it follows from the cookie logic above.

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

Backend

Auth config (if applicable)

typescript
betterAuth({
  session: { expiresIn: 60 * 60 * 24 * 7, updateAge: 60 * 60 * 24 },
  plugins: [username(), admin()],
});

Additional context

We work around it with an after hook. On a successful response that issued a new session (ctx.context.newSession) without issuing dont_remember itself, it expires a validly signed marker the request carried.