# Auth0 Logout Not Fully Clearing Session on Azure Static Web Apps

**URL:** <https://community.auth0.com/t/auth0-logout-not-fully-clearing-session-on-azure-static-web-apps/183178>\
**Category:** Get Help\
**Tags:** sessions, logout\
**Created:** [March 3, 2025, 12:09pm UTC](https://community.auth0.com/t/auth0-logout-not-fully-clearing-session-on-azure-static-web-apps/183178 "2025-03-03T12:09:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dato.bobokhia](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dato.bobokhia/32/73360_2.png) [@dato.bobokhia](https://community.auth0.com/u/dato.bobokhia)\
**Post date:** [March 3, 2025, 12:09pm UTC](https://community.auth0.com/t/auth0-logout-not-fully-clearing-session-on-azure-static-web-apps/183178/1 "2025-03-03T12:09:04Z")

</div>

I’m experiencing an issue where logging out from Auth0 works locally but fails on Azure Static Web Apps. Even after calling `/api/auth/logout`, the session remains active, and Auth0 cookies (`appSession`, `auth_verification`) are restored.

What I Have Tried:

✅ Ensured the Auth0 logout URL is correctly set in the Auth0 dashboard.  
✅ Used `/api/auth/logout` instead of a direct redirect to Auth0’s logout URL.  
✅ Tried clearing cookies manually (client-side and server-side) but `appSession` persists.  
✅ Called `/.auth/logout` before redirecting to `/api/auth/logout`. However, a cors error occurs when making this request.  
✅ Disabled caching using `Cache-Control: no-store, no-cache, must-revalidate`.  
✅ Tested in Incognito mode to rule out local caching.

Observations:

- Deleting cookies manually via the browser instantly logs out the user, but doing so via code does not work.
- Azure appears to be restoring the session cookies after logout.

Questions:

1. Is there a way to prevent Azure from persisting authentication cookies?
2. How can we fully clear the Auth0 session when logging out on Azure Static Web Apps?

---

<div class="post-metadata">

**Author:** ![vlad.murarasu](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vlad.murarasu/32/72793_2.png) [@vlad.murarasu](https://community.auth0.com/u/vlad.murarasu)\
**Post date:** [March 3, 2025, 8:54pm UTC](https://community.auth0.com/t/auth0-logout-not-fully-clearing-session-on-azure-static-web-apps/183178/3 "2025-03-03T20:54:35Z")

</div>

Hi @dato.bobokhia,

Welcome to the Auth0 Community.

I found this issue on the Static Web App Github repo with this comment saying logouts from custom IdPs are not supported:

> <https://github.com/Azure/static-web-apps/issues/594#issuecomment-936921115>
>
> I saw this similar issue and I think this is a bug.
> https://github.com/Azure/st…atic-web-apps/issues/529
> 
> But I would like to understand better if this is something that will be fixed or do we really need to make the "reverse flow" to make it work. (Logout from IdP redirecting to app logout url).
> 
> \*\*Describe the bug\*\*
> The app does not completely logs out when we visit the /logout url with a custom identity provider configured.
> 
> \*\*To Reproduce\*\*
> Steps to reproduce the behavior:
> 1. Setup a custom identity provider
> 2. Login into the app
> 3. Then logout
> 4. The SWA app will be logged out but not the custom provider.
> 5. If you visit any url that requires authentication the app logs you in without requesting for credentials again.
>  
> \*\*Expected behavior\*\*
> Logout from the SWA and from the custom identity provider.

This thread has some fixes that could work for your case.

If you have any other questions feel free to ask us.

Have a good one,  
Vlad

---

<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:** [March 17, 2025, 8:55pm UTC](https://community.auth0.com/t/auth0-logout-not-fully-clearing-session-on-azure-static-web-apps/183178/4 "2025-03-17T20:55:29Z")

</div>

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