# Constructor

Learn how to initialize a cookie.

The constructor initializes the cookie with the given name, value, and attributes.

Only the name and value are required, so you can keep the defaults for the remaining attributes when they suit your response.

## Signature

The constructor has the following signature:

```php
public function __construct(
    string $name,
    string $value,
    ?int $expiration = null,
    string $path = '/',
    ?string $domain = null,
    bool $secure = true,
    bool $httpOnly = false,
    ?string $sameSite = 'None',
)
```

## Example

Here is a basic example of how to initialize a cookie:

```php
<?php
use Croct\Plug\Cookie;

$cookie = new Cookie(
    name: 'ct_client_id',
    value: '7e9d59a9-e4b3-4f8a-b0c1-2d3e4f5a6b7c',
);
```

## Parameters

The following list describes the supported parameters:

- `name`: `string`

  The name of the cookie.

- `value`: `string`

  The value of the cookie.

- `expiration`: `integer` (optional) (default: null)

  The expiration time as a Unix timestamp in seconds. The default is `null`, which makes it a session cookie.

- `path`: `string` (optional) (default: /)

  The path for the cookie.

- `domain`: `string` (optional) (default: null)

  The domain for the cookie. The default is `null`, which scopes the cookie to the current host.

- `secure`: `boolean` (optional) (default: true)

  Whether the cookie is sent only over HTTPS.

- `httpOnly`: `boolean` (optional) (default: false)

  Whether the cookie is hidden from client-side scripts.

- `sameSite`: `string` (optional) (default: None)

  The SameSite policy applied to the cookie.
