---
title: "Wipe local data at sign-out · Agent Wranglers"
url: https://agentwranglers.se/playbook/mobile-apps/data-on-the-device/wipe-on-sign-out
updated: 2026-10-21
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Wipe local data at sign-out

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Data on the device](https://agentwranglers.se/playbook/mobile-apps/data-on-the-device.md).

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

- ID: MOB-25
- Level: Recommended
- Chapter: [Data on the device](https://agentwranglers.se/playbook/mobile-apps/data-on-the-device)
- Rule: Signing out removes the person's tokens, local database, caches and files from the phone. The next person to sign in sees none of it.
- Applies when: The project has user accounts.
- How: Phones are shared, sold and handed in for repair. Keep all of a person's files under one folder or database, so sign-out deletes one place. Clear image and HTTP caches too. Tell the server, so it ends the session and unlinks push, as [unlink push from the account at sign-out](https://agentwranglers.se/playbook/notifications/push-notifications/unlink-push-on-sign-out) says. Warn first when unsynced changes would be lost.
- Check: Sign in as one test user, load data, sign out and sign in as a second user. No screen, search or cache shows the first user's data, and the first user's folder is gone.

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

### Plain text example

```swift
func signOut() async {
    try? await api.post("/sessions/current/end")
    SecItemDelete([kSecClass as String: kSecClassGenericPassword] as CFDictionary)
    try? FileManager.default.removeItem(at: userDataDirectory)
    URLCache.shared.removeAllCachedResponses()
}
```

### Kotlin example

```kotlin
suspend fun signOut() {
    runCatching { api.post("/sessions/current/end") }
    context.deleteDatabase("user.db")
    File(context.filesDir, "user").deleteRecursively()
    context.cacheDir.deleteRecursively()
}
```

## Related rules

- [Unlink push from the account at sign-out](https://agentwranglers.se/playbook/notifications/push-notifications/unlink-push-on-sign-out) in Notifications

**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/mobile-apps/data-on-the-device/wipe-on-sign-out">Agent Wranglers mobile apps playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Encrypt local data that holds personal data](https://agentwranglers.se/playbook/mobile-apps/data-on-the-device/encrypted-local-data)
- Next: [Queue offline changes and resolve conflicts on the server](https://agentwranglers.se/playbook/mobile-apps/data-on-the-device/offline-sync)
- [Data on the device](https://agentwranglers.se/playbook/mobile-apps/data-on-the-device)
