# Invalid State Error After Long Inactivity on Universal Login Page

**URL:** <https://community.auth0.com/t/invalid-state-error-after-long-inactivity-on-universal-login-page/141360>\
**Category:** Get Help\
**Tags:** classic-universal-login-experience, login-experience\
**Created:** [August 20, 2024, 6:35am UTC](https://community.auth0.com/t/invalid-state-error-after-long-inactivity-on-universal-login-page/141360 "2024-08-20T06:35:28Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![zachary.zhao](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/zachary.zhao/32/51104_2.png) [@zachary.zhao](https://community.auth0.com/u/zachary.zhao)\
**Post date:** [August 20, 2024, 11:41pm UTC](https://community.auth0.com/t/invalid-state-error-after-long-inactivity-on-universal-login-page/141360/4 "2024-08-20T23:41:13Z")

</div>

HI @dawid.matuszczyk , Thank you for your response! I really appreciate it.

I have a couple of follow-up questions:

1. In another discussion, it was mentioned that the state is generated by the `webauth.login` method [link to discussion](https://community.auth0.com/t/state-does-not-match/35148/3). I just want to confirm if the state param is already in url, what happen when I call the `webauth.login`? Will the state generate again?
2. In my application, the flow where the user directly navigates to the login page is something we can’t easily change. Given this, I was wondering if there are any workarounds for the “invalid state” issue. For example, does Auth0 provide a method to automatically refresh the state? Or can I just call `login` function again if detect “invalid state” issue?  
Another reply mentioned this [link to discussion](https://community.auth0.com/t/invalid-state-on-reload-auth0-callback-url-using-auth0-spa-js-and-angular-8/36469/10)  
But I am not sure how to `start a new authentication request` in my case.

To be more detailed, here is my current code:

```auto
        function login(e) {
          e.preventDefault();
...
            const username = document.getElementById("email").value;
            const password = document.getElementById("password").value;
            webAuth.login(
              {
                realm: databaseConnection,
                username: username,
                password: password,
              },
              function (err) {
//add the logic of handle invalid state here, but not sure how to do it. 
//Can I just call webAuth.login again? 
//Or I need to redirect to the auth.myXXX.dev again to get the new state?
                if (err) {
                  label.classList.remove("hidden");
                  loader.classList.add("hidden");
                  displayError(err);
                }
              }
            );
          }
        }

```

Thanks again for your help!

---

_[View the full topic](https://community.auth0.com/t/invalid-state-error-after-long-inactivity-on-universal-login-page/141360)._
