# Express-openid-connect isAuthenticated not working properly when logout

**URL:** <https://community.auth0.com/t/express-openid-connect-isauthenticated-not-working-properly-when-logout/130527>\
**Category:** Get Help\
**Tags:** sessions, logout\
**Created:** [March 26, 2024, 3:46pm UTC](https://community.auth0.com/t/express-openid-connect-isauthenticated-not-working-properly-when-logout/130527 "2024-03-26T15:46:44Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![nik.baleca](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nik.baleca/32/68749_2.png) [@nik.baleca](https://community.auth0.com/u/nik.baleca)\
**Post date:** [January 21, 2025, 9:32pm UTC](https://community.auth0.com/t/express-openid-connect-isauthenticated-not-working-properly-when-logout/130527/2 "2025-01-21T21:32:36Z")

</div>

Hi @rafael4

Thank you for posting your inquiry on the Auth0 Community!

I believe that your application does not delete the user cookies upon logout even after all the parameters have been set correctly according to our [OIDC logout documentation](https://auth0.com/docs/api/authentication?http&_gl=1*19s64ol*_gcl_au*MTQ0Mjc1NzMyLjE3MzM4NDI0MjM.*_ga*MTUzMjkzMjI3NS4xNzMzODM0NTky*_ga_QKMSDV5369*MTczNzQ4NjU0My43MS4xLjE3Mzc0ODg5NDcuNDEuMC4w#oidc-logout:~:text=Auth0%20Logout-,OIDC%20Logout,-SAML%20Logout).

You can attempt to delete all the user cookies as a potential workaround as follows:

```auto
/* LOGOUT ROUTER */
router.get('/logout', (req, res) => {
  req.logout();
  if (req.session) {
    req.session.destroy(function (err) {
      if (err) {
        console.log(err)
      }
      console.log("Destroyed the user session on Auth0 endpoint");
      res.redirect('https://<myapp>.auth0.com/v2/logout?client_id=<clientId>&returnTo=http://localhost:3000/');
    });
  }
});

```

Please keep in mind that the `returnTo` address is also under the **Allowed Logout URLs**.

You can read more about terminating an user’s session for OIDC in this [Knowledge Article](https://community.auth0.com/t/logout-not-working-as-cookies-persist/157306)

---

_[View the full topic](https://community.auth0.com/t/express-openid-connect-isauthenticated-not-working-properly-when-logout/130527)._
