|
| 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 | + * @var string |
| 18 | + */ |
| 19 | + public $prefix = ''; |
| 20 | + |
| 21 | + /** |
| 22 | + * -------------------------------------------------------------------------- |
| 23 | + * Cookie Expires Timestamp |
| 24 | + * -------------------------------------------------------------------------- |
| 25 | + * |
| 26 | + * Default expires timestamp for cookies. Setting this to `0` will mean the |
| 27 | + * cookie will not have the `Expires` attribute and will behave as a session |
| 28 | + * cookie. |
| 29 | + * |
| 30 | + * @var DateTimeInterface|integer|string |
| 31 | + */ |
| 32 | + public $expires = 0; |
| 33 | + |
| 34 | + /** |
| 35 | + * -------------------------------------------------------------------------- |
| 36 | + * Cookie Path |
| 37 | + * -------------------------------------------------------------------------- |
| 38 | + * |
| 39 | + * Typically will be a forward slash. |
| 40 | + * |
| 41 | + * @var string |
| 42 | + */ |
| 43 | + public $path = '/'; |
| 44 | + |
| 45 | + /** |
| 46 | + * -------------------------------------------------------------------------- |
| 47 | + * Cookie Domain |
| 48 | + * -------------------------------------------------------------------------- |
| 49 | + * |
| 50 | + * Set to `.your-domain.com` for site-wide cookies. |
| 51 | + * |
| 52 | + * @var string |
| 53 | + */ |
| 54 | + public $domain = ''; |
| 55 | + |
| 56 | + /** |
| 57 | + * -------------------------------------------------------------------------- |
| 58 | + * Cookie Secure |
| 59 | + * -------------------------------------------------------------------------- |
| 60 | + * |
| 61 | + * Cookie will only be set if a secure HTTPS connection exists. |
| 62 | + * |
| 63 | + * @var boolean |
| 64 | + */ |
| 65 | + public $secure = false; |
| 66 | + |
| 67 | + /** |
| 68 | + * -------------------------------------------------------------------------- |
| 69 | + * Cookie HTTPOnly |
| 70 | + * -------------------------------------------------------------------------- |
| 71 | + * |
| 72 | + * Cookie will only be accessible via HTTP(S) (no JavaScript). |
| 73 | + * |
| 74 | + * @var boolean |
| 75 | + */ |
| 76 | + public $httponly = true; |
| 77 | + |
| 78 | + /** |
| 79 | + * -------------------------------------------------------------------------- |
| 80 | + * Cookie SameSite |
| 81 | + * -------------------------------------------------------------------------- |
| 82 | + * |
| 83 | + * Configure cookie SameSite setting. Allowed values are: |
| 84 | + * - None |
| 85 | + * - Lax |
| 86 | + * - Strict |
| 87 | + * - '' |
| 88 | + * |
| 89 | + * Alternatively, you can use the constant names: |
| 90 | + * - `Cookie::SAMESITE_NONE` |
| 91 | + * - `Cookie::SAMESITE_LAX` |
| 92 | + * - `Cookie::SAMESITE_STRICT` |
| 93 | + * |
| 94 | + * Defaults to `Lax` for compatibility with modern browsers. Setting `''` |
| 95 | + * (empty string) means default SameSite attribute set by browsers (`Lax`) |
| 96 | + * will be set on cookies. If set to `None`, `$secure` must also be set. |
| 97 | + * |
| 98 | + * @var string |
| 99 | + */ |
| 100 | + public $samesite = 'Lax'; |
| 101 | + |
| 102 | + /** |
| 103 | + * -------------------------------------------------------------------------- |
| 104 | + * Cookie Raw |
| 105 | + * -------------------------------------------------------------------------- |
| 106 | + * |
| 107 | + * This flag allows setting a "raw" cookie, i.e., its name and value are |
| 108 | + * not URL encoded using `rawurlencode()`. |
| 109 | + * |
| 110 | + * If this is set to `true`, cookie names should be compliant of RFC 2616's |
| 111 | + * list of allowed characters. |
| 112 | + * |
| 113 | + * @var boolean |
| 114 | + * |
| 115 | + * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#attributes |
| 116 | + * @see https://tools.ietf.org/html/rfc2616#section-2.2 |
| 117 | + */ |
| 118 | + public $raw = false; |
| 119 | +} |
0 commit comments