# Session expired

**URL:** https://meta.discourse.org/t/session-expired/317006
**Category:** Development
**Created:** [July 18, 2024, 11:02am UTC](https://meta.discourse.org/t/session-expired/317006 "2024-07-18T11:02:41Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Celso\_Teixeira](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/celso_teixeira/32/355969_2.png) [@Celso\_Teixeira](https://meta.discourse.org/u/Celso_Teixeira)
#### Post date: [July 18, 2024, 11:02am UTC](https://meta.discourse.org/t/session-expired/317006/1 "2024-07-18T11:02:41Z")

</div>

Continued from: [Cloudflare cookie: CF\_Authorization](https://meta.discourse.org/t/cloudflare-cookie-cf-authorization/315893)

We are utilizing Microsoft SSO for login, integrated with OpenID Connect. When users click the forum link, they are redirected to the Microsoft login system, thus no login button is displayed on the forum.

We also use Cloudflare on top of the forum, which includes cookie sessions.

We encounter two issues:

1. Wen the Discourse `_t` cookie session expires, users are redirected to an error page.  

2. When the Cloudflare authorization cookie session expires, users are redirected to an error page.  

Both scenarios redirect users to `domain_url/exception`.

My goal is to automatically reload the forum when these situations occur. This would ensure users are either redirected to the Microsoft login or the cookies are updated based on SSO.

If anyone has alternative solutions, please share.

I tried the following script:

```html
<script>
window.addEventListener('error', function (event) {
     window.open(url, '_self');
}, true);
</script>

```

While it works, it is not smooth as the user can see the error page and it takes a while to reload the page.

Please share any other ideas or improvements for a more seamless user experience.
