# Better detection of "cookies deleted" in the application

**URL:** https://meta.discourse.org/t/better-detection-of-cookies-deleted-in-the-application/78800
**Category:** Feature
**Created:** [1월 23, 2018, 8:38오후 UTC](https://meta.discourse.org/t/better-detection-of-cookies-deleted-in-the-application/78800 "2018-01-23T20:38:07Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [1월 23, 2018, 8:38오후 UTC](https://meta.discourse.org/t/better-detection-of-cookies-deleted-in-the-application/78800/1 "2018-01-23T20:38:07Z")

</div>

Occasionally users may delete all cookies or in self hosted situations (which do not have auth token set via env) junk redis.

When this happens behaviour is kind of odd.

It looks like you are logged in:

 ![image](https://global.discourse-cdn.com/meta/original/3X/8/1/81628938989885feb50037cecf81df34b433a3e6.png)

If you are browsing a secure topic, you only see placeholders:

 ![image](https://global.discourse-cdn.com/meta/original/3X/f/2/f2aff3518157710c2c85c1cb426497b57fdeb029.png)

Depending on the site you are on (requires login or not) you will start seeing lots of 302s or 403s

Instead:

If we detect a user is somehow no longer logged in, we should open a modal saying “looks like you were logged out would you like to refresh” or something along those lines.

We can solve this **very cleanly** , by:

1. Adding a custom HTTP header: `DISCOURSE_LOGGED_IN: true` to all Ajax calls we make (based on what the client thinks.

2. Adding a custom HTTP header to responses from the server when there is a conflict between server and client state: `DISCOURSE_LOGGED_OUT: true`

Then client can easily tell that it was logged out and raise the screen and if anyone anywhere has issues with status codes (due to live permission changes and the like) we will not confuse it with the “logged out” situation.

---

<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: [1월 24, 2018, 3:15오후 UTC](https://meta.discourse.org/t/better-detection-of-cookies-deleted-in-the-application/78800/3 "2018-01-24T15:15:17Z")

</div>

Isn’t this a duplicate and proposed solution to… _gasp_… my first topic on Meta? 😱

> [@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…

Thanks for looking into this 🌞

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [3월 6, 2018, 5:53오전 UTC](https://meta.discourse.org/t/better-detection-of-cookies-deleted-in-the-application/78800/4 "2018-03-06T05:53:57Z")

</div>

Completed per:

[https://github.com/discourse/discourse/commit/0134e41286255111f2644a5b90e03640efef5db1](https://github.com/discourse/discourse/commit/0134e41286255111f2644a5b90e03640efef5db1)

Pretty bullet proof after this change.

---

<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: [3월 6, 2018, 7:48오전 UTC](https://meta.discourse.org/t/better-detection-of-cookies-deleted-in-the-application/78800/5 "2018-03-06T07:48:29Z")

</div>

Wohoo, wonderful! Thank you 🌸

(Sorry to spam you, but a ❤ simply wasn’t enough 😉)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [3월 7, 2018, 7:00오전 UTC](https://meta.discourse.org/t/better-detection-of-cookies-deleted-in-the-application/78800/6 "2018-03-07T07:00:00Z")

</div>

This topic was automatically closed after 25 hours. New replies are no longer allowed.
