# Constructor

Learn how to initialize a cookie storage directly.

The constructor initializes the storage with the given client ID, user token, and cookie settings.

Typically, you create it with one of its factory methods, but you can construct it directly to apply a custom [cookie configuration](../cookie-configuration) or to seed the session in tests.

## Signature

The constructor has the following signature:

```php
public function __construct(
    ?Uuid $clientId = null,
    ?Token $userToken = null,
    ?CookieConfiguration $configuration = null,
    ?int $now = null,
)
```

## Example

Here is a basic example of how to create a cookie storage with a custom configuration:

```php
<?php
use Croct\Plug\CookieConfiguration;
use Croct\Plug\CookieStorage;

$storage = new CookieStorage(
    configuration: new CookieConfiguration(domain: 'example.com'),
);
```

## Parameters

The following list describes the supported parameters:

- `clientId`: `Uuid|null` (optional) (see [Uuid](/reference/sdk/php/api/storage/uuid))

  The visitor's client ID.

- `userToken`: `Token|null` (optional) (see [Token](/reference/sdk/php/api/authentication/token))

  The visitor's user token.

- `configuration`: `CookieConfiguration|null` (optional) (default: null) (see [CookieConfiguration](/reference/sdk/php/api/storage/cookie-configuration))

  The cookie names, lifetimes, and attributes. The default is `null`, which uses the standard configuration.

- `now`: `int|null` (optional) (default: null)

  The current time as a Unix timestamp in seconds, used to compute the cookie expiration. The default is `null`, which uses the current time.
