# User Identification

> The library manages user sessions and identity tracking automatically via cookies and the Segmentify API.

## Session & User IDs

Every event is enriched with two IDs managed as cookies:

| Cookie            | Lifetime | Purpose                                      |
| ----------------- | -------- | -------------------------------------------- |
| `_sgf_session_id` | 24 hours | Identifies a single browsing session         |
| `_sgf_user_id`    | 1 year   | Persists across sessions for returning users |

These are created automatically on the first event. If either is missing, the library fetches new IDs from the Segmentify API.

## Linking to Known Users

You can associate tracked behavior with a known user via:

- **`user` in config** — set at initialization (see [Configuration](/02-configuration))
- **`email` / `externalId` in event payloads** — passed on any event call
- **`Register`, `LogIn`, `Identify` events** — dedicated user operations (see [Events](/05-events))

## Platform Detection

The library detects the user's device automatically using the Bowser library:

| Platform | Value      |
| -------- | ---------- |
| Desktop  | `'PC'`     |
| Mobile   | `'mobile'` |
| Tablet   | `'tablet'` |

This is included in every event payload as part of the enriched `ExtendedPayload`, along with OS name, OS version, and browser.

## See Also

- [Events — User Operations](/05-events#user-operations)
