--- title: "Cross-device consent sharing" slug: "clearing-user-session" updated: 2026-11-17T02:44:12Z published: 2026-11-17T02:44:12Z canonical: "usercentrics.com/clearing-user-session" --- > ## Documentation Index > Fetch the complete documentation index at: https://usercentrics.com/docs/llms.txt > Use this file to discover all available pages before exploring further. # Cross-device consent sharing ### Overview This feature enables the clearing of previously granted user consents, which proves beneficial if your application offers a sign-out functionality. By removing the consents granted by the user, this feature ensures a smooth transition for the next user, eliminating the necessity to reset and reinitialize the SDK. > [!NOTE] > Remote consents will not be deleted > > This feature **only clears the session stored on the local device**; all user consents that can be retrieved using their `controllerId `will remain stored on our servers. ### Examples of use cases - **Sign-out and sign-in flow**: If a login occurs and the current user is not associated in your system with a `controllerId `(which would indicate that their consents can be restored), the Clear User Session function should be called - **Delete user data**: If your app or game includes a feature to delete local user data, this method offers an optimized approach to clear user data while keeping the SDK prepared to collect new consents. ## Implementation > [!WARNING] > Loaded Settings will be kept > > Since this feature will not reinitialize the SDK, all the Settings loaded by the settingsId or rulesetId previously used will be kept. > [!WARNING] > Only call it after the SDK is ready > > `clearUserSession` is only available once the SDK has initialized successfully (**isReady** succeeded). If initialization failed, do not access `UsercentricsCore.shared` (iOS) or `Usercentrics.instance` (Android) to call it, as this throws and, on iOS, terminates the app. Call `configure` (iOS) or `initialize` (Android) again and wait for **isReady** instead. #### Steps for implementation 1. Call the `clearUserSession` API to clear the user session. 2. Session cleanup callback: after invoking the API, verify the successful cleaning of the session. If the cleaning process fails, prompt the user to provide their consents again. ## Clearing the user session You can clear a user session in all Usercentrics supported platforms with the following code: Swift - iOSKotlin - AndroidDart - FlutterTypescript - React NativeC# - Unity ```swift UsercentricsCore.shared.clearUserSession(onSuccess: { status in    // This callback is equivalent to isReady API }, onError: { error in    // Handle non-localized error } ``` ```kotlin Usercentrics.instance.clearUserSession({ status ->    // This callback is equivalent to isReady API }, { error ->    // Handle non-localized error }) ``` ```dart try {  final status = await Usercentrics.clearUserSession();  // This callback is equivalent to isReady API } catch (error) {  // Handle non-localized error } ``` ```typescript import { Usercentrics } from '@usercentrics/react-native-sdk'; try {  const status = await Usercentrics.clearUserSession();  // This callback is equivalent to isReady API } catch (error) {  // Handle non-localized error } ``` ```csharp Usercentrics.Instance.ClearUserSession((status) => {    // This callback is equivalent to isReady API }, (errorString) => {    // Handle non-localized error }); ``` ## Best practices #### Avoid routine invocation - Ensure this API is called only when necessary, as invoking it excessively could burden your end-users' experience - Within the context of signing in and out, you can eliminate the need to call this API by restoring a user session directly. Check out [this page](/v1/docs/restoring-a-user-session-cross-device-consent-sharing#graphical-overview) for more detailed instructions