---
title: "Sign out every open tab together · Agent Wranglers"
url: https://agentwranglers.se/playbook/app-ui/sessions-and-permissions/sign-out-all-tabs
id: APP-59
level: Recommended
applies: accounts
updated: 2026-10-22
build: a2a6bdfed830
tokens: 1003
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Sign out every open tab together

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Sessions and permissions](https://agentwranglers.se/playbook/app-ui/sessions-and-permissions.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-22.

- ID: APP-59
- Level: Recommended
- Chapter: [Sessions and permissions](https://agentwranglers.se/playbook/app-ui/sessions-and-permissions.md)
- Rule: When a person signs out or switches account in one tab, every other open tab hides the old account's data within 2 seconds. A tab never shows one account's data under another account's name.
- Check: A browser test signs in, opens a customer list in two tabs and signs out in the first. Within 2 seconds the second tab shows the sign-in page, and 0 customer names remain in its page text.
- Applies when: The project has user accounts.
- How: After sign-out or an account switch, post a message on a `BroadcastChannel`, such as `session`, with the new user ID or none. Each tab listens, clears its data cache and in-memory state, and loads the sign-in page or the new account's start screen. A tab that missed the message, such as one asleep in the background, checks the user ID on its next response. Wipe what the browser stored, as [wipe browser data on sign-out](https://agentwranglers.se/playbook/application-security/authentication-and-sessions/clear-site-data-on-sign-out.md) says. End the session on the server, as [sign out of one device or all of them](https://agentwranglers.se/playbook/accounts/sessions-and-security-activity/revoke-sessions.md) says.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### TypeScript example

```ts
const sessionChannel = new BroadcastChannel('session');

export function announceSessionChange(userId: string | null) {
  sessionChannel.postMessage({ userId });
}

sessionChannel.addEventListener('message', ({ data }) => {
  if (data.userId === currentUserId) return;
  queryClient.clear();
  location.assign(data.userId ? '/' : '/sign-in');
});
```

### Python example

```python
def test_sign_out_reaches_other_tabs(context):
    first, second = context.new_page(), context.new_page()
    for page in (first, second):
        page.goto("https://app.example.com/customers")
    first.get_by_role("button", name="Sign out").click()
    expect(second).to_have_url(re.compile(r"/sign-in$"), timeout=2000)
    expect(second.get_by_text("Northwind Traders")).to_have_count(0)
```

## Sources

- [HTML Standard on broadcasting to other browsing contexts](https://html.spec.whatwg.org/multipage/web-messaging.html#broadcasting-to-other-browsing-contexts)

## Related rules

- APS-19 [Clear cached pages and data when someone signs out](https://agentwranglers.se/playbook/application-security/authentication-and-sessions/clear-site-data-on-sign-out.md) in Application security
- ACC-28 [Let people sign out of one device or all of them](https://agentwranglers.se/playbook/accounts/sessions-and-security-activity/revoke-sessions.md) in Accounts and identity

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/app-ui/sessions-and-permissions/sign-out-all-tabs">Agent Wranglers web app interface playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Survive an expired session](https://agentwranglers.se/playbook/app-ui/sessions-and-permissions/session-expiry.md)
- Next: [Show who changed a record and when](https://agentwranglers.se/playbook/app-ui/sessions-and-permissions/record-history.md)
- [Sessions and permissions](https://agentwranglers.se/playbook/app-ui/sessions-and-permissions.md)
