---
title: "Sign out every open tab together · Agent Wranglers"
url: https://agentwranglers.se/playbook/app-ui/permissions-flags-and-failures/sign-out-all-tabs
updated: 2026-10-21
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 [Permissions, flags and failures](https://agentwranglers.se/playbook/app-ui/permissions-flags-and-failures.md).

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

- ID: APP-59
- Level: Recommended
- Chapter: [Permissions, flags and failures](https://agentwranglers.se/playbook/app-ui/permissions-flags-and-failures)
- 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.
- 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/website/security/clear-site-data) 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) says.
- 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.

## 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

- [Wipe browser data on sign-out](https://agentwranglers.se/playbook/website/security/clear-site-data) in Website
- [Let people sign out of one device or all of them](https://agentwranglers.se/playbook/accounts/sessions-and-security-activity/revoke-sessions) in Accounts

**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/permissions-flags-and-failures/sign-out-all-tabs">Agent Wranglers 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/permissions-flags-and-failures/session-expiry)
- Next: [Read feature flags before the first paint](https://agentwranglers.se/playbook/app-ui/permissions-flags-and-failures/feature-flags-in-ui)
- [Permissions, flags and failures](https://agentwranglers.se/playbook/app-ui/permissions-flags-and-failures)
