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

# clearSession

> Sign out a Client Auth session and return Portal to uninitialized.

## Function Signature

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

## Description

Signs out the [Client Auth](../guide/client-auth) session `Portal` was initialized with. It drops the in-memory token, deletes the persisted copy, and returns `Portal` to uninitialized: call `initialize(session:)` with the session from the next sign-in before using `Portal` again.

It does not emit on [`onSessionInvalidated`](./onsessioninvalidated), and does not revoke anything server-side: the token stays valid until the backend expires it. The wallet's signing shares are not touched.

A no-op when `Portal` was initialized with an API key, or is not initialized.

Pair it with [`PortalAuth().clearPersistedSession()`](./portalauthclearpersistedsession), and run that even when `clearSession()` throws, so the next launch cannot restore the session.

Available starting from `portal_flutter` 2.0.0.

## Parameters

This method takes no parameters.

## Returns

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

## 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.code}): ${e.message}');
  }

  await PortalAuth().clearPersistedSession();
}
```

## Errors

| Code | Description |
| - | - |
| `CLEAR_SESSION_ERROR` | The session could not be cleared, for example because secure storage failed |

## Related

* [End the session guide](../guide/client-auth#end-the-session)
* [clearPersistedSession](./portalauthclearpersistedsession)
* [onSessionInvalidated](./onsessioninvalidated)


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