@@ -156,32 +156,38 @@ export function ensureSessionIssuedAt(session: Session, now: number = Date.now()
156156}
157157
158158/**
159- * Commits the session for an authenticated user, setting `issuedAt = now` and
160- * the cookie's `Max-Age` to the effective session duration. Use this at every
161- * login/MFA-completion point so the session window starts fresh.
159+ * The auth cookie's `Max-Age` is intentionally long (1 year) so the cookie
160+ * always reaches the server. Actual session expiry is enforced server-side
161+ * via `sessionIssuedAt` against the user's effective duration. If we let the
162+ * cookie expire client-side, the user is silently logged out without the
163+ * "signed out due to inactivity" toast.
164+ */
165+ const AUTH_COOKIE_MAX_AGE_SECONDS = DEFAULT_SESSION_DURATION_SECONDS ;
166+
167+ /**
168+ * Commits the session for an authenticated user, setting `issuedAt = now`.
169+ * Use this at every login/MFA-completion point so the session window starts
170+ * fresh. Cookie `Max-Age` is fixed; expiry is enforced server-side.
162171 */
163172export async function commitAuthenticatedSession (
164173 session : Session ,
165- userId : string ,
174+ _userId : string ,
166175 now : number = Date . now ( )
167176) : Promise < string > {
168- const { durationSeconds } = await getEffectiveSessionDuration ( userId ) ;
169177 setSessionIssuedAt ( session , now ) ;
170- return commitSession ( session , { maxAge : durationSeconds } ) ;
178+ return commitSession ( session , { maxAge : AUTH_COOKIE_MAX_AGE_SECONDS } ) ;
171179}
172180
173181/**
174182 * Commits the session for an authenticated user, lazily backfilling
175183 * `issuedAt` if missing. Use on every authenticated response that already
176- * commits the cookie (e.g. root.tsx) so legacy cookies migrate forward and
177- * the browser's stored Max-Age tracks the latest effective duration.
184+ * commits the cookie (e.g. root.tsx).
178185 */
179186export async function commitAuthenticatedSessionLazy (
180187 session : Session ,
181- userId : string ,
188+ _userId : string ,
182189 now : number = Date . now ( )
183190) : Promise < string > {
184- const { durationSeconds } = await getEffectiveSessionDuration ( userId ) ;
185191 ensureSessionIssuedAt ( session , now ) ;
186- return commitSession ( session , { maxAge : durationSeconds } ) ;
192+ return commitSession ( session , { maxAge : AUTH_COOKIE_MAX_AGE_SECONDS } ) ;
187193}
0 commit comments