identify

Learn how to associate the current session with a user.

This method identifies the visitor with an identifier that is unique to your application.

It generates an unsigned token for the user and reconciles the visitor session accordingly. If the user ID changes during a session, the current session is terminated and a new one is started.

For more information, see Data collection.

Signature

This method has the following signature:

public function identify(string $userId): void

Example

Here is a basic example of how to use this method:

<?phpuse Croct\Plug\Croct;
$croct = Croct::fromDotenv();$croct->identify('john-doe');

Parameters

The following list describes the supported parameters:

userId
string

The ID that uniquely identifies the user in your application.

You can use any unique identifier, such as an email address, a username, or a customer ID.