Persisting login session on Angular app reload

I am using the Auth0 sample project provided for Angular and experience strange behavior. I am able to login and use the application, but when the application is reloaded while a login session is active, the login session is lost and the app is redirected to the login page again. Upon investigating, I found that the cookie being created upon logging is persists just fine when the app reloads (and the flag in that cookie “auth0.is.authenticated”) is true. Example: if I am running my app on localhost:3000, a cookie for this resource “http://localhost:3000” is created, but when the app is reloaded, a different cookie with the resource “https://dev.I0f-*********.auth0.com” is created. This new resource is my domain name of my application in Auth0, and because in the sample Angular app we are looking at the current client cookie (which is this new one on app reload), it doesnt find the “auth0.is.authenticated” flag and hence takes the user back to the login page. Therefore, I think if I can figure out why this new cookie for a different client is getting created on app reload, I will be able to understand what is happening.

Hi @sahlawat11,

Welcome to the Community!

There should be a localhost cookie and a {tenant}.auth0.com cookie. The localhost cookie will have the flag, and the auth0 cookie is used to maintain a login session with the auth server. This is used to login silently in an iframe after the refresh.

Can you make sure there is no conflicting cookies or sessions by trying to login and refresh in an incognito or private browsing window?

If this does not solve the issue, we can dive deeper.

Thanks,
Dan

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