# Getting the Logged-in User

When the user authenticates successfully, Cotter's SDK will automatically store the logged-in user in the device's secure storage.

To get the user information, call `cotter.getUser()` :

```dart
Cotter cotter = new Cotter(apiKeyID: API_KEY_ID);
void getLoggedInUser() async {
  try {
    var user = await cotter.getUser();
    print(user);
  } catch (e) {
    print(e);
  }
}
```

This function returns the [User object](https://docs.cotter.app/api-reference/user-api/user-object).

If the user's `id_token` is expired, this function will automatically attempt to refresh the token, resulting in refreshing the user's session, and return the User object if successful. Otherwise, this function will throw an error if the session is expired.

{% hint style="warning" %}
Please use the identifier (email/phone number) as your main way to identify users, **Cotter's User ID is deprecated.**
{% endhint %}
