# I want to set session expiry specific to a user

**URL:** <https://community.auth0.com/t/i-want-to-set-session-expiry-specific-to-a-user/193936>\
**Category:** Get Help\
**Tags:** signup-prompt-new-experience, login-experience\
**Created:** [October 30, 2025, 1:29pm UTC](https://community.auth0.com/t/i-want-to-set-session-expiry-specific-to-a-user/193936 "2025-10-30T13:29:39Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![remus.ivan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/remus.ivan/32/68771_2.png) [@remus.ivan](https://community.auth0.com/u/remus.ivan)\
**Post date:** [October 31, 2025, 4:32pm UTC](https://community.auth0.com/t/i-want-to-set-session-expiry-specific-to-a-user/193936/3 "2025-10-31T16:32:54Z")

</div>

Hi @khushbu,

Welcome back to the Auth0 Community!

> [@khushbu](#):
>
> Anyway to know the users last login time. So that I can set the session expiry on that.

You have identified correctly how to get the user’s last login, since the Date.now() function takes place right after a successful login since it executes in a Post-Login Action. This could also be checked using the [event.session.created\_at](https://auth0.com/docs/customize/actions/explore-triggers/signup-and-login-triggers/login-trigger/post-login-event-object) option ( note that this option is only available for Enterprise Customers )

> [@khushbu](#):
>
> I want to update session expiry for user’s complete session. Any way to do that ?

Since you are mentioning ‘complete session’, my guess is that you are trying to set an absolute lifetime for the user session. You action’s code looks correct to me, but a more robust action code that should work for your use case could be similar to:

```auto
exports.onExecutePostLogin = async (event, api) => {

const currentTimeMs = new Date().getTime(); // Date.now() would work as well
const tenSeconds = 10 * 1000;
const absolute = currentTimeMs + tenSeconds;
api.session.setExpiresAt(absolute);
api.refreshToken.setExpiresAt(absolute);
console.log(`setting expiration: `, absolute);
};

```

You could also check if the session exists, but please note that, but also be aware that [Session ID in a Post Login Action](https://support.auth0.com/center/s/article/Session-ID-in-a-post-login-action) is listed as options and can be undefined. Please also not that **the API.session.setIdleExpiresAt(idle)** method sets the session inactivity timeout for the current interaction. If the method is not reapplied, subsequent successful interactions will override the inactivity timeout using the session inactivity timeout settings.

I hope this helps and if you have further questions please let me know!  
Thank you,  
Remus

---

_[View the full topic](https://community.auth0.com/t/i-want-to-set-session-expiry-specific-to-a-user/193936)._
