# SSO Session Idle vs SSO Session Max

**URL:** <https://forum.keycloak.org/t/sso-session-idle-vs-sso-session-max/16542>\
**Category:** Getting advice\
**Created:** [July 20, 2022, 10:53am UTC](https://forum.keycloak.org/t/sso-session-idle-vs-sso-session-max/16542 "2022-07-20T10:53:15Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![amir](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@amir](https://forum.keycloak.org/u/amir)\
**Post date:** [July 20, 2022, 10:53am UTC](https://forum.keycloak.org/t/sso-session-idle-vs-sso-session-max/16542/1 "2022-07-20T10:53:15Z")

</div>

By love of god - I can’t understand what is the difference between “SSO Session Idle” and “SSO Session Max”!

![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/e/ead5bb7ca2518d065048d82968c82618e44f224b.png)

this is what I found from googling:  
“SSO Session Idle Specify the SSO Session Idle timeout. By default, the value is set to 30 minutes. **SSO Session Max Specify the maximum time before a user session is expired and invalidated**. By default, the value is set to 10 hours”

In our scenario, we are doing a user login using the Admin Rest API.  
and once the access token is explored we use the refresh token to create a new one.  
from what I noticed that once I do that the refresh token expiration is rest to 30 minutes again.  
so what is this 10 hours parameter?

our goal is that if a user is idle for more than 1 hour - he will need to do login again.  
what is the best way to achieve this ?

thank!

---

<div class="post-metadata">

**Author:** ![edwint88](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/edwint88/32/1103_2.png) [@edwint88](https://forum.keycloak.org/u/edwint88)\
**Post date:** [July 20, 2022, 2:40pm UTC](https://forum.keycloak.org/t/sso-session-idle-vs-sso-session-max/16542/2 "2022-07-20T14:40:25Z")

</div>

[https://wjw465150.gitbooks.io/keycloak-documentation/content/server\_admin/topics/sessions/timeouts.html](https://wjw465150.gitbooks.io/keycloak-documentation/content/server_admin/topics/sessions/timeouts.html)  
Basically you need SSO Session Idle 60 Minutes  
And the SSO Session Max is the max time a user can remain active, after that he needs another valid session. (your user ca start to be active after 59 Minutes about 10 times, afterwards he will need another session)

---

<div class="post-metadata">

**Author:** ![amir](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@amir](https://forum.keycloak.org/u/amir)\
**Post date:** [July 24, 2022, 7:52am UTC](https://forum.keycloak.org/t/sso-session-idle-vs-sso-session-max/16542/3 "2022-07-24T07:52:56Z")

</div>

@edwint88  
thanks for the reply!  
just to make sure I got it right.  
if I set SSO Session Max to 10 hours - so even if the user is active for 10 hours (and I’m using the refresh token to generate a new access token) - after 10- hours i can longer refresh the access token and the user session is no longer active (and i will have to log him out so he can reconnect)?

---

<div class="post-metadata">

**Author:** ![Aldi1990](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/aldi1990/32/11258_2.png) [@Aldi1990](https://forum.keycloak.org/u/Aldi1990)\
**Post date:** [September 16, 2024, 8:42pm UTC](https://forum.keycloak.org/t/sso-session-idle-vs-sso-session-max/16542/4 "2024-09-16T20:42:17Z")

</div>

@amir  
I have exacly the same problem, because I have set session idle time to 30 minutes and my application has logic where every request check validy access\_token or time of expires refresh token. Could youn found reslove of this problem?

---

<div class="post-metadata">

**Author:** ![amir](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@amir](https://forum.keycloak.org/u/amir)\
**Post date:** [September 17, 2024, 4:16am UTC](https://forum.keycloak.org/t/sso-session-idle-vs-sso-session-max/16542/5 "2024-09-17T04:16:14Z")

</div>

not sure I understand what your problem is.  
all I wanted was to understand the difference and @edwint88 explained it pretty well

---

<div class="post-metadata">

**Author:** ![Aldi1990](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/aldi1990/32/11258_2.png) [@Aldi1990](https://forum.keycloak.org/u/Aldi1990)\
**Post date:** [September 17, 2024, 7:19am UTC](https://forum.keycloak.org/t/sso-session-idle-vs-sso-session-max/16542/6 "2024-09-17T07:19:44Z")

</div>

@admir  
Maybe I’ll explain it again. My problem is where I set SSO Session idle on 5 minutes and whatever I do on app, Keycloak always finish my session after 5 minutes.

In keykloack events is information that refresh token works and in user’s session is information about update last access.

---

<div class="post-metadata">

**Author:** ![amir](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@amir](https://forum.keycloak.org/u/amir)\
**Post date:** [September 17, 2024, 8:17am UTC](https://forum.keycloak.org/t/sso-session-idle-vs-sso-session-max/16542/7 "2024-09-17T08:17:34Z")

</div>

From what I recall (since we left Keycloak a while ago) if you set the SSO Session idle to 5 minutes that means that after 5 minutes the token will expire.  
I think that in KC you need to check the expiration time before any action you do and if the expiration is about to expire (let’s say in 3 seconds) you need to refresh the token using KC (we used the API of KC so we refreshed it manually) and then the token will be valid for another 5 minutes

The “sso session max” means that no matter how many times you will refresh the token - after a certain time (lets say 10 hours) the session can’t be refresh anymore and new token need to be created

from what i recall the industry standards are:  
access token should be 5 minutes  
refresh token (SSO Session idle ) should be around 120 minutes  
sso session max depends on business logic if you want a user \service token to be valid forever or not

but again, it’s all up to your needs

---

<div class="post-metadata">

**Author:** ![Aldi1990](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/aldi1990/32/11258_2.png) [@Aldi1990](https://forum.keycloak.org/u/Aldi1990)\
**Post date:** [September 17, 2024, 8:46am UTC](https://forum.keycloak.org/t/sso-session-idle-vs-sso-session-max/16542/8 "2024-09-17T08:46:42Z")

</div>

@admir  
For the test I set below parametrs.  
SSO Session Idle - 5 minutes  
SSO Session Max - 10 hours  
Access Token Lifespan - 1 minutes

Every request on my app check validy access token. If expires\_in is expired then refresh token get new access token. The parameters changed after each access token refresh

![lol](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/7/7431f9d2dbac779b8f7680d2557121c0f223e02d.jpeg)

---

<div class="post-metadata">

**Author:** ![Aldi1990](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/aldi1990/32/11258_2.png) [@Aldi1990](https://forum.keycloak.org/u/Aldi1990)\
**Post date:** [September 17, 2024, 8:47am UTC](https://forum.keycloak.org/t/sso-session-idle-vs-sso-session-max/16542/9 "2024-09-17T08:47:26Z")

</div>

After time SSO Session idle I see in events below information

 ![var2](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/6/6e4fc9d5827d503e8224a6e36a06ec71aabf9ef9.jpeg)
