What is the recommended way for session refresh? #3837
-
Hi folks. We have started integrating Ory Kratos with our React SPA application and backend service. I want to keep active user's session active while the session without recent activity expires.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Refreshing the session by starting a new login flow with However, it isn't the right approach to just keeping a session active, which you want to happen transparently to the user in the background. The way we have dealt with this is our API has an |
Beta Was this translation helpful? Give feedback.
Refreshing the session by starting a new login flow with
?refresh=true
will force the user to re-enter their password. This is good for cases where you want to re-verify the user, such as when they are about to perform some destructive action.However, it isn't the right approach to just keeping a session active, which you want to happen transparently to the user in the background.
The way we have dealt with this is our API has an
extend session
, which in turn calls Kratos's backend API extendSession method. We have our apps configured so that on startup they call this API to extend the session. This works fine for our requirement of "user stays logged in for up to 2 weeks of inactivity".