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: 2 comments 3 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.
-
|
Maybe useful to note that aeneasr said on the session renew PR that automatic extension by read operations like /whoami would be suceptible to CSRF He is referencing to this comment on the issue that preceded the PR So the current conclusion is that no config would auto refresh by read only operations like whoami So the current available methods (as seen on that PR) is exactly what @MichaelMarner said in his comment
More info in the docs: |
Beta Was this translation helpful? Give feedback.
Refreshing the session by starting a new login flow with
?refresh=truewill 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".