Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| Cookie | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | n/a |
0 / 0 |
|||
| 1 | <?php |
| 2 | |
| 3 | namespace Config; |
| 4 | |
| 5 | use CodeIgniter\Config\BaseConfig; |
| 6 | use DateTimeInterface; |
| 7 | |
| 8 | class Cookie extends BaseConfig |
| 9 | { |
| 10 | /** |
| 11 | * -------------------------------------------------------------------------- |
| 12 | * Cookie Prefix |
| 13 | * -------------------------------------------------------------------------- |
| 14 | * |
| 15 | * Set a cookie name prefix if you need to avoid collisions. |
| 16 | */ |
| 17 | public string $prefix = ''; |
| 18 | |
| 19 | /** |
| 20 | * -------------------------------------------------------------------------- |
| 21 | * Cookie Expires Timestamp |
| 22 | * -------------------------------------------------------------------------- |
| 23 | * |
| 24 | * Default expires timestamp for cookies. Setting this to `0` will mean the |
| 25 | * cookie will not have the `Expires` attribute and will behave as a session |
| 26 | * cookie. |
| 27 | * |
| 28 | * @var DateTimeInterface|int|string |
| 29 | */ |
| 30 | public $expires = 0; |
| 31 | |
| 32 | /** |
| 33 | * -------------------------------------------------------------------------- |
| 34 | * Cookie Path |
| 35 | * -------------------------------------------------------------------------- |
| 36 | * |
| 37 | * Typically will be a forward slash. |
| 38 | */ |
| 39 | public string $path = '/'; |
| 40 | |
| 41 | /** |
| 42 | * -------------------------------------------------------------------------- |
| 43 | * Cookie Domain |
| 44 | * -------------------------------------------------------------------------- |
| 45 | * |
| 46 | * Set to `.your-domain.com` for site-wide cookies. |
| 47 | */ |
| 48 | public string $domain = ''; |
| 49 | |
| 50 | /** |
| 51 | * -------------------------------------------------------------------------- |
| 52 | * Cookie Secure |
| 53 | * -------------------------------------------------------------------------- |
| 54 | * |
| 55 | * Cookie will only be set if a secure HTTPS connection exists. |
| 56 | */ |
| 57 | public bool $secure = false; |
| 58 | |
| 59 | /** |
| 60 | * -------------------------------------------------------------------------- |
| 61 | * Cookie HTTPOnly |
| 62 | * -------------------------------------------------------------------------- |
| 63 | * |
| 64 | * Cookie will only be accessible via HTTP(S) (no JavaScript). |
| 65 | */ |
| 66 | public bool $httponly = true; |
| 67 | |
| 68 | /** |
| 69 | * -------------------------------------------------------------------------- |
| 70 | * Cookie SameSite |
| 71 | * -------------------------------------------------------------------------- |
| 72 | * |
| 73 | * Configure cookie SameSite setting. Allowed values are: |
| 74 | * - None |
| 75 | * - Lax |
| 76 | * - Strict |
| 77 | * - '' |
| 78 | * |
| 79 | * Alternatively, you can use the constant names: |
| 80 | * - `Cookie::SAMESITE_NONE` |
| 81 | * - `Cookie::SAMESITE_LAX` |
| 82 | * - `Cookie::SAMESITE_STRICT` |
| 83 | * |
| 84 | * Defaults to `Lax` for compatibility with modern browsers. Setting `''` |
| 85 | * (empty string) means default SameSite attribute set by browsers (`Lax`) |
| 86 | * will be set on cookies. If set to `None`, `$secure` must also be set. |
| 87 | * |
| 88 | * @var ''|'Lax'|'None'|'Strict' |
| 89 | */ |
| 90 | public string $samesite = 'Lax'; |
| 91 | |
| 92 | /** |
| 93 | * -------------------------------------------------------------------------- |
| 94 | * Cookie Raw |
| 95 | * -------------------------------------------------------------------------- |
| 96 | * |
| 97 | * This flag allows setting a "raw" cookie, i.e., its name and value are |
| 98 | * not URL encoded using `rawurlencode()`. |
| 99 | * |
| 100 | * If this is set to `true`, cookie names should be compliant of RFC 2616's |
| 101 | * list of allowed characters. |
| 102 | * |
| 103 | * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#attributes |
| 104 | * @see https://tools.ietf.org/html/rfc2616#section-2.2 |
| 105 | */ |
| 106 | public bool $raw = false; |
| 107 | } |