# Force All Users To Sign Out

If you are using cookie-based authentication and you want to sign out all users (so that they have to re-authenticate), you need to invalidate all of the cookies.

Because the cookies live in the client's browser, you cannot simply clear them like you would with session-based authentication. Instead, you need to replace the session token used to create all those cookies.

First, get a new token:

```bash
$ bundle exec rake secret
538696c1399ff182486e09980ba915d098b8fb23a3ace42c3eea0ab51b18fdff7895cd620f32b263d10d25c2fdba16647f4d8632e9032eccef7406e1ad9cba09
```

Then, replace the current `secret_key_base` value with that new secret token [wherever it is stored](https://api.rubyonrails.org/classes/Rails/Application.html#method-i-secret_key_base) in the production environment.

[source](https://stackoverflow.com/questions/35190591/rails-4-devise-how-to-log-out-all-users)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ploegert.gitbook.io/til/programmy/rails/force-all-users-to-sign-out.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
