<@U04UQ68083H> how can I keep a user indefinitely ...
# ory-copilot
a
@chilly-king-10285 how can I keep a user indefinitely logged in, without challenging them for credentials if they use my app every day and session expiration is set to 72 hours or more?
c
A message from kapa.ai
Hmm, I don't know enough to give you a confident answer yet. However, you can extend the session lifespan by adjusting the
earliest_possible_extend
configuration. For example, if you set
earliest_possible_extend
to
lifespan
, sessions can be refreshed during their entire lifespan, even right after they are created. This means that as long as the user is active within the session lifespan, the session will be constantly refreshed and they won't be challenged for credentials. Here is how you can set
earliest_possible_extend
to
lifespan
using the Ory CLI:
Copy code
bash ## List all available projects   ory list projects      ## Get config   ory get identity-config {project-id} --format yaml > identity-config.yaml
Then, update the configuration value for the property to the desired value in the
identity-config.yaml
file:
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: 72h   earliest_possible_extend: lifespan
Finally, update the Ory Identities configuration using the file you worked with:
Copy code
bash ory update identity-config {project-id} --file identity-config.yaml
Please note that this will result in all sessions being constantly refreshed, which might not be the desired behavior in all scenarios. For more information, you can refer to the [Ory documentation](https://www.ory.sh/docs/kratos/session-management/refresh-extend-sessions).
a
I’m getting this error: The request was malformed or contained invalid parameters Unable to validate config: I[#/session/earliest_possible_extend] S[#/properties/session/properties/earliest_possible_extend/pattern] does not match pattern “^([0-9]+(ns|us|ms|s|m|h))+$”
@chilly-king-10285 I’m getting this error: The request was malformed or contained invalid parameters Unable to validate config: I[#/session/earliest_possible_extend] S[#/properties/session/properties/earliest_possible_extend/pattern] does not match pattern “^([0-9]+(ns|us|ms|s|m|h))+$”
c
A message from kapa.ai
The error message you're seeing is indicating that the value you've set for
earliest_possible_extend
in your configuration does not match the expected pattern. The pattern
^([0-9]+(ns|us|ms|s|m|h))+$
expects a numeric value followed by a time unit (ns for nanoseconds, us for microseconds, ms for milliseconds, s for seconds, m for minutes, h for hours). In the previous example,
earliest_possible_extend
was set to
lifespan
, which is not a valid value according to the pattern. Instead, you should set it to a specific time duration. For example, if you want to allow sessions to be extended 24 hours before they expire, you would set
earliest_possible_extend
to
24h
. Here's how you can do it:
Copy code
bash ## List all available projects   ory list projects      ## Get config   ory get identity-config {project-id} --format yaml > identity-config.yaml
Then, update the configuration value for the property to the desired value in the
identity-config.yaml
file:
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: 72h   earliest_possible_extend: 24h
Finally, update the Ory Identities configuration using the file you worked with:
Copy code
bash ory update identity-config {project-id} --file identity-config.yaml
For more information, you can refer to the [Ory documentation](https://www.ory.sh/docs/kratos/session-management/refresh-extend-sessions).