auth.session.persistent. Without it there are no new routes, cookies or tables, and error bodies stay as they were.
1. Upgrade the packages
Move@glinr/theauth, and @glinr/theauth-client and @glinr/theauth-react if you use them, to the releases that include persistent sessions. Upgrade @glinr/theauth-cli with them to get the doctor checks.
2. Check your session lifetime
Startup fails whenpersistent.idleTimeoutMs is not longer than the session maxAge:
maxAge defaults to 7 days and idleTimeoutMs to 30. If you raised maxAge to keep people signed in, lower it now, since the remember cookie takes over that job. A day or less is a reasonable starting point.
3. Apply migration 0016
It createstheauth_session_families and theauth_session_family_tokens and changes no existing table. It runs only when auth.session.persistent is set.
SQL Server users run
applyMssqlSchema, which creates the two tables. Prisma users also add the two models to their schema.
4. Know what changes once it is on
If you delete session rows yourself, with SQL or your own scripts, the device behind them can still refresh. Call
theauth.persistentSessions.revokeBySession or revokeAll instead.
5. Configure
- Every instance gets the same remember secret.
- Behind a TLS terminating proxy,
trustedProxyis set. Without it anhttpsbase URL makes the refresh route answerinsecure_transport. - A frontend on another origin is listed in the handler’s
trustedOrigins. The remember cookie isSameSite=Lax, so that origin must be on the same site as the auth routes.
6. Update the client
Without this step the checkbox has no visible effect.- With
@glinr/theauth-clientor@glinr/theauth-react, pass{ remember }tosignInand send your API calls through the store’sfetch. See client and React. - With your own client, refresh once and retry once on
session_expired, and never send users to sign-in on a network error, 429 or 5xx. - Server rendered pages call
refreshFromRequestin the page gate, or therefreshPageSessionof your framework adapter. - A Next.js app using
@glinr/theauth-nextjs-authsetspersistent. - With
createTheAuthGoClient, passremembertologin,signuporpasskeys.login.
7. Add a device list
Build a “your devices” screen onGET /auth/session-families, with rename, sign out and forget. It differs from a sessions list: a remembered device whose session has expired still appears, with live: false.
8. Roll it out
- Deploy with migration 0016 applied and the flag off.
- Ship the client change. It does nothing while the feature is off.
- Turn the flag on in staging. Sign in with the box ticked, delete the session cookie in the browser, reload, and confirm one refresh followed by the retried request.
- Turn it on in production. To limit it to a group of users first, return
falsefromeligiblefor everyone else. - Watch for
session.reuse_detected. A steady stream usually means a client or proxy dropsSet-Cookieheaders or restores old cookies.
theauth doctor against the config to catch very long lifetimes.
Turn it off again
Removeauth.session.persistent and deploy. The refresh and device routes disappear, remember cookies are ignored, and users sign in again when their current session ends. Sessions already issued stay valid until they expire.
The rows stay in the database, and revocations made while the feature is off do not update them. If you may turn it back on, empty both tables first, or old remember cookies that have not expired can work again:
Downgrade
Turn the feature off first, then roll the packages back.- Migration
0016is additive, so an older version of@glinr/theauthruns against the migrated database. It ignores both tables, andtheauth db statuslists0016as unknown to that version. This does not stop startup. - Remove the
persistentkey from your config if the older version’s types reject it. - A session that was created by a refresh may show an extra
theauthRefreshedkey insession.metadataon the older version until it expires. - Client packages can be rolled back on their own. An older client does not refresh, so users sign in again when their session ends.
0016 as applied and does not recreate them: