Constructor
Learn how to initialize a cookie configuration.
The constructor initializes the cookie configuration with the settings you provide.
Every parameter is optional, so you can override only the settings you need and keep the defaults for the rest.
Signature
The constructor has the following signature:
public function __construct( string $clientIdName = 'ct_client_id', string $userTokenName = 'ct_user_token', int $clientIdDuration = 31536000, int $userTokenDuration = 604800, ?string $domain = null, bool $secure = true, string $sameSite = 'None',)Example
Here is a basic example of how to initialize a cookie configuration:
<?phpuse Croct\Plug\CookieConfiguration;
$configuration = new CookieConfiguration( domain: 'example.com', sameSite: 'Lax',);Parameters
The following list describes the supported parameters:
- clientIdName(optional)string
The name of the client ID cookie.
Default:ct_client_id- userTokenName(optional)string
The name of the user token cookie.
Default:ct_user_token- clientIdDuration(optional)integer
The lifetime of the client ID cookie, in seconds. The default is 31536000 seconds, which is one year.
Default:31536000- userTokenDuration(optional)integer
The lifetime of the user token cookie, in seconds. The default is 604800 seconds, which is one week.
Default:604800- domain(optional)string|null
The domain for the cookies. The default is null, which scopes the cookies to the current host.
Default:null- secure(optional)boolean
Whether the cookies are sent only over HTTPS.
Default:true- sameSite(optional)string
The SameSite policy applied to the cookies.
Default:None