# Auth0 cookie expirey while on universal login page

**URL:** <https://community.auth0.com/t/auth0-cookie-expirey-while-on-universal-login-page/39491>\
**Category:** Get Help\
**Tags:** auth0\
**Created:** [March 16, 2020, 8:07pm UTC](https://community.auth0.com/t/auth0-cookie-expirey-while-on-universal-login-page/39491 "2020-03-16T20:07:30Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![albert.lockett](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/albert.lockett/32/19868_2.png) [@albert.lockett](https://community.auth0.com/u/albert.lockett)\
**Post date:** [March 16, 2020, 8:07pm UTC](https://community.auth0.com/t/auth0-cookie-expirey-while-on-universal-login-page/39491/1 "2020-03-16T20:07:30Z")

</div>

Hi,

I was looking for some guidance on what happens when the cookies that get set by the /authorize endpoint expire while the user is on the unversal login page.

Here’s some background - I’m using the auth0 spa sdk navigate my users over to the unversal login page using the loginWithRedirect() method. Periodically, users will report that they get a response like this after they enter their credentials and click Login:

```auto
{“statusCode”:403,“description”:“Invalid state”,“name”:“AnomalyDetected”,“code”:“access_denied”}

```

that comes from the /usernamepassword/login endpoint

I can replicate the issue by going to my app, having it navigate me to the universal login screen, then delete some cookies my auth0 domain (cookie values auth0, auth0\_compat and \_csrf), then login using my username and password.

I’m wondering if it’s possible my user’s cookies expire while they’re sitting on the universal login page which is causing this issue for them. The reason I think this is, usually they will report it first thing in the morning. I think what’s happening is:

- they logged out of application at end of day
- let their computer sit on the login screen all night
- the cookies expire
- the morning when they try to log in they get this response.

Does this makes sense? If so, I am hoping to get some guidance on how those cookies are set, and what I could do to mitigate against this.

I can see that when I call loginWithRedirect() from the auth0 spa sdk, it sends the browser to /authorize which sends 302 response plus the set-cookie headers only if the cookies aren’t set already. I am wondering how auth0 determines the expirey time for those cookies, and if there is any logic in the /authorize endpoint that says “I see the cookies are set, but they will expire soon, so I will set a newer values”

I am also wondering what I could do to mitigate against this situation? If my users are going to sit on the universal login page for quite a while, could I put some custom javascript on my universal login page that would check the cookie expiration, and handle getting some new ones if they’re going to expire (maybe by redirecting back to my app, then back to auth0)?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [March 17, 2020, 9:22pm UTC](https://community.auth0.com/t/auth0-cookie-expirey-while-on-universal-login-page/39491/3 "2020-03-17T21:22:45Z")

</div>

Hi @albert.lockett,

Welcome to the Community!

You could be getting this error for a few reasons, one of which could be a user disabling cookies for the login page, but that is less likely. It is more likely that they have bookmarked the login page. Check out this page for info on that:

> **[Configure Default Login Routes](https://auth0.com/docs/authenticate/login/auth0-universal-login/configure-default-login-routes)**
>
> Learn how to configure your tenant's and application's default login routes.

Another possible cause could be misusing the back button.

Do you think that could be the case?

Thanks,  
Dan

---

<div class="post-metadata">

**Author:** ![albert.lockett](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/albert.lockett/32/19868_2.png) [@albert.lockett](https://community.auth0.com/u/albert.lockett)\
**Post date:** [March 17, 2020, 10:11pm UTC](https://community.auth0.com/t/auth0-cookie-expirey-while-on-universal-login-page/39491/4 "2020-03-17T22:11:26Z")

</div>

Hey Dan,

I checked with our users who are having this issue and they are not bookmarking the login page, which makes sense because otherwise they wouldn’t be getting this issue intermittently. They also told me they said they aren’t bookmarking the login page.

Please, do you know if it makes sense that the cookies could expire while they are on the universal login page and if it could cause this issue?

---

<div class="post-metadata">

**Author:** ![albert.lockett](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/albert.lockett/32/19868_2.png) [@albert.lockett](https://community.auth0.com/u/albert.lockett)\
**Post date:** [March 18, 2020, 1:42pm UTC](https://community.auth0.com/t/auth0-cookie-expirey-while-on-universal-login-page/39491/5 "2020-03-18T13:42:01Z")

</div>

@dan.woda I figured out another way to reproduce this.

If the user logs out of the application in two different tabs, and on each tab they are then redirected to the universal login screen, it seems like the cookies that get set on the second tab will over-write the values on the first tab.

If you then try to login on the first tab, you’ll get the response from the original post (403, AnomolyDetected).

Do you have any guidance on finding a solution for that?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [March 18, 2020, 7:36pm UTC](https://community.auth0.com/t/auth0-cookie-expirey-while-on-universal-login-page/39491/6 "2020-03-18T19:36:38Z")

</div>

> [@albert.lockett](#):
>
> Please, do you know if it makes sense that the cookies could expire while they are on the universal login page and if it could cause this issue?

If they are logging in and out every day the should not be getting expired cookies like this, unless I am mistaken.

> [@albert.lockett](#):
>
> If the user logs out of the application in two different tabs, and on each tab they are then redirected to the universal login screen, it seems like the cookies that get set on the second tab will over-write the values on the first tab.

Did you look into setting up a default login route that I linked above? I think that could solve this issue.

---

<div class="post-metadata">

**Author:** ![albert.lockett](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/albert.lockett/32/19868_2.png) [@albert.lockett](https://community.auth0.com/u/albert.lockett)\
**Post date:** [March 31, 2020, 7:51pm UTC](https://community.auth0.com/t/auth0-cookie-expirey-while-on-universal-login-page/39491/7 "2020-03-31T19:51:53Z")

</div>

@dan.woda  
If I understand you correctly, if I set up the default login route, after my users get the “403/Anomaly Detected” response they would get redirected to my configured default login route, which would navigate them back to the universal login page, and they could try to log in again?

---

<div class="post-metadata">

**Author:** ![albert.lockett](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/albert.lockett/32/19868_2.png) [@albert.lockett](https://community.auth0.com/u/albert.lockett)\
**Post date:** [March 31, 2020, 8:05pm UTC](https://community.auth0.com/t/auth0-cookie-expirey-while-on-universal-login-page/39491/8 "2020-03-31T20:05:23Z")

</div>

I did set up the default login route but it did not resolve the issue. Is there any additional information I can provide to help make this easier from a support perspective?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [March 31, 2020, 10:00pm UTC](https://community.auth0.com/t/auth0-cookie-expirey-while-on-universal-login-page/39491/9 "2020-03-31T22:00:07Z")

</div>

If you could provide me a HAR file of one of these transactions from your customers that could be very helpful.

> **[Generate and Analyze HAR Files](https://auth0.com/docs/troubleshoot/troubleshooting-tools/generate-and-analyze-har-files)**
>
> Learn how to troubleshoot with HAR files and steps to generate a HAR file.

---

<div class="post-metadata">

**Author:** ![albert.lockett](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/albert.lockett/32/19868_2.png) [@albert.lockett](https://community.auth0.com/u/albert.lockett)\
**Post date:** [March 31, 2020, 10:36pm UTC](https://community.auth0.com/t/auth0-cookie-expirey-while-on-universal-login-page/39491/10 "2020-03-31T22:36:52Z")

</div>

Thanks Dan, sounds good. Can I send it to you directly, or is the expectation that I post it here on the public forum?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [March 31, 2020, 10:37pm UTC](https://community.auth0.com/t/auth0-cookie-expirey-while-on-universal-login-page/39491/11 "2020-03-31T22:37:31Z")

</div>

Please DM it to me, thanks!

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [April 21, 2020, 9:16pm UTC](https://community.auth0.com/t/auth0-cookie-expirey-while-on-universal-login-page/39491/13 "2020-04-21T21:16:33Z")

</div>

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