<@U04UQ68083H> How can I update expire_at attribut...
# ory-copilot
d
@chilly-king-10285 How can I update expire_at attribute of existing ory authentication cookie? SetCookie add another cookie instead of overriding existing one
c
A message from kapa.ai
The
expire_at
attribute of an existing Ory authentication cookie is automatically managed by the Ory system and is based on the session lifespan configuration. You cannot directly update the
expire_at
attribute of an existing cookie. However, you can change the session lifespan or refresh the session, which indirectly affects the
expire_at
attribute. To change the session lifespan, you can use the Ory CLI to update the configuration value for the session lifespan property. Here's how you can do it: 1. Download the Ory Identities config from your project and save it to a file:
Copy code
bash ory list projects   ory get identity-config {project-id} --format yaml > identity-config.yaml
2. Update the configuration value for session lifespan 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: 720h0m0s
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
In this example, the session lifespan is set to 720 hours (30 days). You can adjust this value as needed. To refresh a session, you can interact with the
/self-service/login/browser
or
/self-service/login/api
APIs and set the
refresh
parameter to true. When you refresh a session, its
expires
property is set to a value that is the time when the refresh is triggered plus the amount of time defined by the value of
/session/lifespan
. Here's an example of how to force a session refresh:
Copy code
bash https://{project.slug}.<http://projects.oryapis.com/self-service/login/browser?refresh=true|projects.oryapis.com/self-service/login/browser?refresh=true>
Please note that refreshing a session will require the user to re-authenticate. For more details, you can refer to the [Ory documentation](https://www.ory.sh/docs/kratos/session-management/overview#ory-session) and [Ory Session Management](https://www.ory.sh/docs/kratos/session-management/overview#using-ory-session-cookie).