2022-03-14 19:13:10 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Config;
|
|
|
|
|
|
|
|
use CodeIgniter\Config\BaseConfig;
|
|
|
|
use DateTimeInterface;
|
|
|
|
|
|
|
|
class Cookie extends BaseConfig
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
* Cookie Prefix
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* Set a cookie name prefix if you need to avoid collisions.
|
|
|
|
*/
|
2024-04-07 22:17:30 +02:00
|
|
|
public string $prefix = '';
|
2022-03-14 19:13:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
* Cookie Expires Timestamp
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* Default expires timestamp for cookies. Setting this to `0` will mean the
|
|
|
|
* cookie will not have the `Expires` attribute and will behave as a session
|
|
|
|
* cookie.
|
|
|
|
*
|
|
|
|
* @var DateTimeInterface|int|string
|
|
|
|
*/
|
|
|
|
public $expires = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
* Cookie Path
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* Typically will be a forward slash.
|
|
|
|
*/
|
2024-04-07 22:17:30 +02:00
|
|
|
public string $path = '/';
|
2022-03-14 19:13:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
* Cookie Domain
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* Set to `.your-domain.com` for site-wide cookies.
|
|
|
|
*/
|
2024-04-07 22:17:30 +02:00
|
|
|
public string $domain = '';
|
2022-03-14 19:13:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
* Cookie Secure
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* Cookie will only be set if a secure HTTPS connection exists.
|
|
|
|
*/
|
2024-04-07 22:17:30 +02:00
|
|
|
public bool $secure = false;
|
2022-03-14 19:13:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
* Cookie HTTPOnly
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* Cookie will only be accessible via HTTP(S) (no JavaScript).
|
|
|
|
*/
|
2024-04-07 22:17:30 +02:00
|
|
|
public bool $httponly = true;
|
2022-03-14 19:13:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
* Cookie SameSite
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* Configure cookie SameSite setting. Allowed values are:
|
|
|
|
* - None
|
|
|
|
* - Lax
|
|
|
|
* - Strict
|
|
|
|
* - ''
|
|
|
|
*
|
|
|
|
* Alternatively, you can use the constant names:
|
|
|
|
* - `Cookie::SAMESITE_NONE`
|
|
|
|
* - `Cookie::SAMESITE_LAX`
|
|
|
|
* - `Cookie::SAMESITE_STRICT`
|
|
|
|
*
|
|
|
|
* Defaults to `Lax` for compatibility with modern browsers. Setting `''`
|
|
|
|
* (empty string) means default SameSite attribute set by browsers (`Lax`)
|
|
|
|
* will be set on cookies. If set to `None`, `$secure` must also be set.
|
|
|
|
*
|
2024-04-07 22:17:30 +02:00
|
|
|
* @phpstan-var 'None'|'Lax'|'Strict'|''
|
2022-03-14 19:13:10 +01:00
|
|
|
*/
|
2024-04-07 22:17:30 +02:00
|
|
|
public string $samesite = 'Lax';
|
2022-03-14 19:13:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
* Cookie Raw
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* This flag allows setting a "raw" cookie, i.e., its name and value are
|
|
|
|
* not URL encoded using `rawurlencode()`.
|
|
|
|
*
|
|
|
|
* If this is set to `true`, cookie names should be compliant of RFC 2616's
|
|
|
|
* list of allowed characters.
|
|
|
|
*
|
|
|
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#attributes
|
|
|
|
* @see https://tools.ietf.org/html/rfc2616#section-2.2
|
|
|
|
*/
|
2024-04-07 22:17:30 +02:00
|
|
|
public bool $raw = false;
|
2022-03-14 19:13:10 +01:00
|
|
|
}
|