# How to deal with expired \`state\` in login uri?

**URL:** <https://community.auth0.com/t/how-to-deal-with-expired-state-in-login-uri/186503>\
**Category:** Get Help\
**Tags:** login-experience, new-universal-login-experience\
**Created:** [May 8, 2025, 7:30pm UTC](https://community.auth0.com/t/how-to-deal-with-expired-state-in-login-uri/186503 "2025-05-08T19:30:37Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dreagan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dreagan/32/73296_2.png) [@dreagan](https://community.auth0.com/u/dreagan)\
**Post date:** [May 8, 2025, 7:30pm UTC](https://community.auth0.com/t/how-to-deal-with-expired-state-in-login-uri/186503/1 "2025-05-08T19:30:37Z")

</div>

QA noticed a bug with the following behavior:

- User navigates to our web app.
- User is not auth’d, so app redirects to app’s auth0 login page.
- If user sits on the app’s auth0 login page for some amount of time (30+ mins?), and THEN attempts to login, the browser redirects briefly to the app (the app’s configured `initiate_login_uri`), then back to the app’s auth0 login page.
- Once user logs in again, the browser redirects to the app successfully.

Based on this documentation: at auth0-universal-login/configure-default-login-routes#users-bookmark-login-page (it won’t let me include links in my post?)

I’m assuming the problem is essentially:

“The `state` parameter points to a record in an internal database where we track the status of the authorization transaction. Whenever the transaction completes, or after a set time passes, the record is deleted from the internal database.”

Is it likely that this is the root cause of the issue I described above?

If so:  
Is there a way to configure the “set time [that] passes”? If not, is there a recommended approach to work-around this rather annoying UX?

If not:  
What else might the issue be?

---

<div class="post-metadata">

**Author:** ![teodor.andrei](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/teodor.andrei/32/75320_2.png) [@teodor.andrei](https://community.auth0.com/u/teodor.andrei)\
**Post date:** [May 9, 2025, 11:56am UTC](https://community.auth0.com/t/how-to-deal-with-expired-state-in-login-uri/186503/3 "2025-05-09T11:56:52Z")

</div>

Hi @dreagan, and welcome to the Auth0 Community!

I’m sorry to hear about the unpleasant UX experience. As this [knowledge article](https://community.auth0.com/t/validate-state-parameter/125562) explains, it is not possible to extend the duration of the state parameter, as this is a security measure.

Perhaps an alternative for a better UX would be to display a friendly message to the user after a period of inactivity, with a button to refresh their session (sending them back to the login page with a new state).

I hope this helps, and don’t hesitate to ask more!

Sincerely,  
Teodor.

---

<div class="post-metadata">

**Author:** ![dreagan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dreagan/32/73296_2.png) [@dreagan](https://community.auth0.com/u/dreagan)\
**Post date:** [May 9, 2025, 12:30pm UTC](https://community.auth0.com/t/how-to-deal-with-expired-state-in-login-uri/186503/4 "2025-05-09T12:30:37Z")

</div>

> Perhaps an alternative for a better UX would be to display a friendly message to the user after a period of inactivity, with a button to refresh their session (sending them back to the login page with a new state).

The issue I describe doesn’t have anything to do with inactivity in the _app_, though.

The issue is, once the user gets to the app’s auth0 login page, if they sit there for some time, and attempt to login, it doesn’t work & they must login again. This same issue could arise even with your suggestion above!

---

<div class="post-metadata">

**Author:** ![teodor.andrei](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/teodor.andrei/32/75320_2.png) [@teodor.andrei](https://community.auth0.com/u/teodor.andrei)\
**Post date:** [May 9, 2025, 12:53pm UTC](https://community.auth0.com/t/how-to-deal-with-expired-state-in-login-uri/186503/5 "2025-05-09T12:53:57Z")

</div>

Yes, I was referring specifically to the login page when I talked about inactivity. I apologize for the misunderstanding.

While it does not solve the problem entirely, the alternative I mentioned let’s the user know that their session is about to expire.

---

<div class="post-metadata">

**Author:** ![dreagan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dreagan/32/73296_2.png) [@dreagan](https://community.auth0.com/u/dreagan)\
**Post date:** [May 9, 2025, 2:04pm UTC](https://community.auth0.com/t/how-to-deal-with-expired-state-in-login-uri/186503/6 "2025-05-09T14:04:14Z")

</div>

> Yes, I was referring specifically to the login page when I talked about inactivity. I apologize for the misunderstanding.
> 
> While it does not solve the problem entirely, the alternative I mentioned let’s the user know that their session is about to expire.

Ok, I’m a bit confused…the login page is the auth0 login page (as I mentioned in my original post). How would we modify the behavior of this page? How would we, for example, add inactivity behavior to the app’s auth0 login page?

---

<div class="post-metadata">

**Author:** ![dreagan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dreagan/32/73296_2.png) [@dreagan](https://community.auth0.com/u/dreagan)\
**Post date:** [May 9, 2025, 2:19pm UTC](https://community.auth0.com/t/how-to-deal-with-expired-state-in-login-uri/186503/7 "2025-05-09T14:19:33Z")

</div>

To clarify, I’m confused, because I didn’t think the universal login experience can be customized with custom javascript, etc? Can it?

---

<div class="post-metadata">

**Author:** ![teodor.andrei](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/teodor.andrei/32/75320_2.png) [@teodor.andrei](https://community.auth0.com/u/teodor.andrei)\
**Post date:** [May 9, 2025, 3:15pm UTC](https://community.auth0.com/t/how-to-deal-with-expired-state-in-login-uri/186503/8 "2025-05-09T15:15:37Z")

</div>

Oh, my bad. That is correct. The New Universal Login page cannot be customized with code. If you were to add the custom JavaScript, it would change to the Classic Login. That doesn’t leave you with an option to change the behaviour, sorry for misguiding you!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [June 20, 2025, 12:00pm UTC](https://community.auth0.com/t/how-to-deal-with-expired-state-in-login-uri/186503/9 "2025-06-20T12:00:36Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
