few-oyster-74399
06/12/2025, 1:09 PMbrief-egg-61061
06/12/2025, 1:09 PMbrief-egg-61061
06/12/2025, 1:09 PM720h
as the session lifespan, and click Save. 2. Ory CLI: Download your current configuration, update the session lifespan, and upload it back: bash # Download config ory get identity-config --project <project-id> --workspace <workspace-id> --format yaml > identity-config.yaml
Edit your identity-config.yaml
to include: yaml session: cookie: domain: $<http://PROJECT_SLUG.projects.oryapis.com|PROJECT_SLUG.projects.oryapis.com> name: ory_session_{name} path: / persistent: false same_site: Lax lifespan: 720h
Then update your project: bash ory update identity-config --project <project-id> --workspace <workspace-id> --file identity-config.yaml
This will keep the user session valid for 30 days, effectively implementing a "trust me for 30 days" feature. If you want the session cookie to persist even after the browser is closed, ensure the persistent
flag is set appropriately for your use case. By default, the session cookie's max-age
matches the session lifespan, so the browser will keep the session for 30 days unless the user logs out or the session is revoked. For more details, see the official documentation on [session lifespan](https://www.ory.sh/docs/kratos/session-management/session-lifespan#session-lifespan)<source>https://www.ory.sh/docs/kratos/session-management/session-lifespan</source>.few-oyster-74399
06/12/2025, 1:48 PMfew-oyster-74399
06/12/2025, 1:48 PMbrief-egg-61061
06/12/2025, 1:48 PMbrief-egg-61061
06/12/2025, 1:49 PMprivileged_session_max_age
). After this period, even if the session is still valid, the user may be required to re-authenticate with 2FA for privileged actions [Privileged sessions](https://www.ory.sh/docs/kratos/session-management/session-lifespan#privileged-sessions). - AAL2 Does Not Expire Automatically: Once a session is at AAL2 (2FA), it remains at that level for the session's duration. The AAL does not automatically downgrade after a set time, and there is no built-in timer for AAL2 expiration. If you want to require 2FA again after a certain period, you must implement this logic yourself by checking the time since the last AAL2 authentication (using the authentication_methods
property in the session object) [Confusing documentation and interface description for AAL and privileged session](https://github.com/ory/network/issues/244). Summary: You can set a 30-day session for users who log in with 2FA, but if you want to require 2FA again after a certain period (shorter than the session lifespan), you need to use the privileged session timer or implement custom logic to enforce re-authentication with 2FA for sensitive actions. There is no built-in "trust this device for 30 days for 2FA" toggle—session and 2FA timing are managed separately.few-oyster-74399
06/12/2025, 2:06 PMbrief-egg-61061
06/12/2025, 2:06 PMbrief-egg-61061
06/12/2025, 2:06 PMbrief-egg-61061
06/12/2025, 2:07 PMpersistent
flag, but the actual session lifetime remains a global setting [Session lifespan](https://www.ory.sh/docs/kratos/session-management/session-lifespan#session-lifespan). If you need per-session or per-user session lifetimes (such as a "remember me" feature), you would need to implement custom logic outside of the standard Ory Kratos configuration. This is not supported natively according to the current documentation. Summary: No, you cannot dynamically set the session lifetime per user at login using a checkbox with Ory Kratos' built-in features. The session lifetime is a global configuration value.brief-egg-61061
06/12/2025, 2:07 PMbrief-egg-61061
06/12/2025, 2:07 PMbrief-egg-61061
06/12/2025, 2:08 PM