> ## Documentation Index
> Fetch the complete documentation index at: https://docs.portalhq.io/llms.txt
> Use this file to discover all available pages before exploring further.

# clearPersistedSession

> Delete the session persisted on this device without needing an initialized Portal.

## Function Signature

```dart theme={null}
Future<void> clearPersistedSession()
```

## Description

A [`PortalAuth`](./portalauth) method. Deletes the persisted session for the configured auth environment, so a later [`restoreSession`](./portalauthrestoresession) returns `null`, and forgets the grant [`handleRedirect`](./portalauthhandleredirect) last exchanged.

This is not a sign-out on its own: an initialized `Portal` that already holds the session keeps working. To sign a user out, call [`Portal().clearSession()`](./clearsession), then this method.

Available starting from `portal_flutter` 2.0.0.

## Parameters

This method takes no parameters.

## Returns

**`Future<void>`** - Completes once the stored session is deleted.

## Example

```dart theme={null}
import 'package:portal_flutter/portal_flutter.dart';

Future<void> signOut() async {
  try {
    await Portal().clearSession();
  } on PortalException catch (e) {
    print('clearSession failed: ${e.message}');
  }

  // Runs even when clearSession() failed.
  await PortalAuth().clearPersistedSession();
}
```

## Errors

| Code | Description |
| - | - |
| `AUTH_NOT_CONFIGURED` | Called before [`configure`](./portalauthconfigure) |
| `AUTH_SESSION_STORAGE_FAILURE` | Secure storage failed this time. It may succeed on the next attempt |
| `AUTH_CLEAR_PERSISTED_SESSION_ERROR` | Any other failure |

## Related

* [End the session guide](../guide/client-auth#end-the-session)
* [clearSession](./clearsession)
* [restoreSession](./portalauthrestoresession)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.