thankful-secretary-66849
07/11/2025, 12:11 AMbrief-egg-61061
07/11/2025, 12:11 AMbrief-egg-61061
07/11/2025, 12:11 AM/sessions/whoami
endpoint or the toSession
SDK method. Example code is provided for both Go and TypeScript SDKs: go func RefreshSession(ctx context.Context, sessionId string) (session *client.Session, err error) { session, _, err = ory.IdentityApi.ExtendSession(ContextWithToken(ctx), sessionId).Execute() if err != nil { return nil, err } return session, err }
typescript export async function refreshSession(sessionId: string) { return await identity.extendSession({ id: sessionId, }) }
[Refresh/extend sessions](https://www.ory.sh/docs/kratos/session-management/refresh-extend-sessions) 2. Session Cookie Handling: - Extending the session in the database does not automatically update the session cookie in the user's browser. After extending the session, you must ensure the client receives the updated cookie. One approach is to call the whoami
(or toSession
) endpoint after extending the session and replace the old cookie with the new one returned by this endpoint. This ensures the session cookie's expiration matches the extended session in the backend. This workaround is discussed in a [GitHub issue](https://github.com/ory/kratos/issues/4441). 3. No Automatic Link Between Hydra Token Refresh and Kratos Session: - The documentation does not describe a built-in way for Hydra's refresh token flow to automatically trigger a Kratos session extension. You would need to implement this logic in your application: when you detect a Hydra access token refresh (e.g., in your OAuth2 callback or token endpoint logic), you should also call the Kratos session extension API for the corresponding user session. Summary: You must manually extend the Kratos session (using the admin API) when you refresh the user's Hydra access token, and ensure the session cookie is updated on the client. There is no automatic synchronization between Hydra token refresh and Kratos session extension in the current Ory documentation and examples. If you need a seamless experience, you will have to implement this coordination in your application logic, as described above. [Refresh/extend sessions](https://www.ory.sh/docs/kratos/session-management/refresh-extend-sessions) [GitHub issue: Extending a session is not working](https://github.com/ory/kratos/issues/4441)thankful-secretary-66849
07/11/2025, 12:41 AMbrief-egg-61061
07/11/2025, 12:41 AMbrief-egg-61061
07/11/2025, 12:41 AM720h
for 30 days). When the session lifespan expires, the user must re-authenticate. There is no documented way to create a session that never expires (i.e., an infinite or "non-expiring" session). The session will always expire after the configured lifespan, and the documentation does not mention support for unlimited or permanent sessions [Session lifespan](https://www.ory.sh/docs/kratos/session-management/session-lifespan). If you require very long sessions, you can set a large lifespan value, but true non-expiring sessions are not supported according to the current documentation.thankful-secretary-66849
07/11/2025, 2:31 PMbrief-egg-61061
07/11/2025, 2:31 PMbrief-egg-61061
07/11/2025, 2:31 PMthankful-secretary-66849
07/11/2025, 5:05 PMbrief-egg-61061
07/11/2025, 5:06 PMbrief-egg-61061
07/11/2025, 5:06 PMyaml selfservice: flows: settings: required_aal: highest_available session: whoami: required_aal: highest_available
If these are not set, users may not be prompted for 2FA after the initial login, especially in native app API flows [Step-up authentication](https://www.ory.sh/docs/kratos/mfa/step-up-authentication). Summary: If users are not being asked for 2FA on API requests in native apps, it is likely because the MFA enforcement model is set to Lax or the required AAL is not configured for those flows. Adjust your configuration to enforce 2FA as needed.