<@U04UQ68083H> I have self hosted ory kratos on my...
# ory-copilot
l
@chilly-king-10285 I have self hosted ory kratos on my local system, I need to configure the session lifespan after the successful login flow
c
A message from kapa.ai
To configure the session lifespan after a successful login flow in your self-hosted Ory Kratos, you need to modify the session lifespan property in the Ory Identities configuration. Here are the steps: 1. Download the Ory Identities config from your project and save it to a file. You can do this using the Ory CLI with the following commands:
Copy code
bash ## List all available projects   ory list projects      ## Get config   ory get identity-config {project-id} --format yaml > identity-config.yaml
2. Update the configuration value for the session lifespan property to the desired value. The session lifespan is expressed in hours, minutes, and seconds. Use a combination of these units to define the desired lifespan. For example:
72h
,
10m
,
12s
,
1h13m3s
. Here is an example of how to set the session lifespan to 30 days (720 hours):
Copy code
yaml session:   cookie:    domain: {project.slug}.<http://projects.oryapis.com|projects.oryapis.com>    name: ory_session_{name}    path: /    persistent: false    same_site: Lax   lifespan: 720h
3. Update the Ory Identities configuration using the file you worked with:
Copy code
bash ory update identity-config {project-id} --file identity-config.yaml
After these steps, each session will be valid for the set amount of time. When the session lifespan expires, the user must re-authenticate. For more details, you can refer to the [Ory Kratos documentation](https://www.ory.sh/docs/kratos/session-management/session-lifespan).
l
@chilly-king-10285 but it will only update the session lifespan in the ory website account
c
A message from kapa.ai
I apologize for the confusion. The instructions provided are indeed for updating the session lifespan in the Ory cloud console. For a self-hosted Ory Kratos setup, you need to update the session lifespan in your local Kratos configuration file. The configuration file is usually named
kratos.yml
or
kratos.json
. Here's an example of how to set the session lifespan in the configuration file:
Copy code
yaml session:   lifespan: 720h
This sets the session lifespan to 30 days (720 hours). The lifespan is expressed in hours (
h
), minutes (
m
), and seconds (
s
). You can use a combination of these units to define the desired lifespan. After updating the configuration file, you need to restart your Kratos service for the changes to take effect. Please refer to the [Ory Kratos documentation](https://www.ory.sh/docs/kratos/session-management/session-lifespan) for more details.