# Network error once session is expired

**URL:** https://meta.discourse.org/t/network-error-once-session-is-expired/74485
**Category:** Feature
**Created:** [November 21, 2017, 5:46am UTC](https://meta.discourse.org/t/network-error-once-session-is-expired/74485 "2017-11-21T05:46:18Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![sebastien](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@sebastien](https://meta.discourse.org/u/sebastien)
#### Post date: [November 21, 2017, 5:46am UTC](https://meta.discourse.org/t/network-error-once-session-is-expired/74485/1 "2017-11-21T05:46:18Z")

</div>

Hi guys,

Some users tend to keep Discourse opened for weeks/months. Unfortunately, users get a “network error” when they are trying to browse the forum with an expired session.

 ![test](https://global.discourse-cdn.com/meta/original/3X/1/9/19470a1a40bcdeab03dc6fd1f9314b453dd366a2.png)

I can easily reproduce this behavior by setting the session expiry time to 1 hour, wait 1 hour and try to open my profile or a topic… Eventually i would get this network error issue.

From my perspective, we should redirect the users to the login/sso page when their session is expired. Is there anyway to achieve that?

Thank,  
Seb

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [November 21, 2017, 11:30am UTC](https://meta.discourse.org/t/network-error-once-session-is-expired/74485/7 "2017-11-21T11:30:17Z")

</div>

Sorry for the noise, let’s start over here.

How long are they keeping the browser open, exactly, and on which page? The browser pings us periodically so it should stay alive pretty much forever.

If you don’t want sessions to expire, then why did you change the setting from its default of 1440 hours (that’s 60 days) to _one hour?_

 ![image](https://global.discourse-cdn.com/meta/original/3X/9/3/93f1492f5e6359de5560458847b428e558db05d0.png)

Are you really telling us that you expect your users to keep the browser open for _more than 60 days?_

---

<div class="post-metadata">

### Author: ![sebastien](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@sebastien](https://meta.discourse.org/u/sebastien)
#### Post date: [November 22, 2017, 1:17am UTC](https://meta.discourse.org/t/network-error-once-session-is-expired/74485/11 "2017-11-22T01:17:51Z")

</div>

Hi,

Thank you for your answer. My beloved users never restart their computer and tend to have tons of tabs loaded. They keep the main page opened and then from time to time, they open topics/their profile… I don’t expect/want them to keep it opened but that’s what they are doing… When I tell them to close all tabs they answer me “no because then I will have to login again” 😄

I would expect users to be redirected to the login/sso page once their session expires.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [November 22, 2017, 1:21am UTC](https://meta.discourse.org/t/network-error-once-session-is-expired/74485/12 "2017-11-22T01:21:55Z")

</div>

Sure @falco had an idea to follow up here but did not post it in public for some reason. Perhaps he should? 😉

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [November 22, 2017, 1:29am UTC](https://meta.discourse.org/t/network-error-once-session-is-expired/74485/13 "2017-11-22T01:29:28Z")

</div>

I had this exact same problem. That was one of the reasons I did the PR for a shorter session in the first place.

When the session cookies expires Discourse get’s crazy. A public topic will get loaded, but timings, notifications and everything will start to fail silently and will eventually break.

Ideally we would have a exception treatment in our Discourse.ajax function that would popup saying that the session expired, click to refresh/login.

This would help enterprise setups with small sessions (because of IT audits or shared computers) and tab hoarders alike.

We just need to be careful to capture this correctly. I think it’s when your xhr gets a 302 with location being `${Discourse.base_url}\login`.

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [November 22, 2017, 9:29am UTC](https://meta.discourse.org/t/network-error-once-session-is-expired/74485/14 "2017-11-22T09:29:11Z")

</div>

I think this is a duplicate of my very first bug report from back in 2015 🙂

> [@Errors after missing a logout notification](https://meta.discourse.org/t/errors-after-missing-a-logout-notification/30527):
>
> When a Discourse tab is open, and the user is logged out remotely (by strict logout or the admin), normally, you receive a push notification that tells you you were logged out and need to refresh this page. If this notification is missed, multiple things error out. Steps to reproduce: log in to a test account disconnect from the network use an admin account on another device to logout the test user reconnect to the network try to use Discourse, e.g. open your profile I’d expect that Discour…

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [November 22, 2017, 2:52pm UTC](https://meta.discourse.org/t/network-error-once-session-is-expired/74485/15 "2017-11-22T14:52:09Z")

</div>

Yes. Now it’s a bit worse because you can have a session lifetime shorter than forever, so it’s not only when you miss a notification.
