wppaste
WordPress

Cookie

Source
wp-includes/Requests/src/Cookie.php:21
Cookie storage object

Compatibility

WordPress
core
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Properties · 5

$namestringpublic
Cookie name.
$valuestringpublic
Cookie value.
$attributesWpOrg\Requests\Utility\CaseInsensitiveDictionary|arraypublic
Cookie attributes
$flagsarraypublic
Cookie flags
$reference_timeintpublic
Reference time for relative calculations

Methods · 12

Source code

class Cookie {	/**	 * Cookie name.	 *	 * @var string	 */	public $name; 	/**	 * Cookie value.	 *	 * @var string	 */	public $value; 	/**	 * Cookie attributes	 *	 * Valid keys are `'path'`, `'domain'`, `'expires'`, `'max-age'`, `'secure'` and	 * `'httponly'`.	 *	 * @var \WpOrg\Requests\Utility\CaseInsensitiveDictionary|array Array-like object	 */	public $attributes = []; 	/**	 * Cookie flags	 *	 * Valid keys are `'creation'`, `'last-access'`, `'persistent'` and `'host-only'`.	 *	 * @var array	 */	public $flags = []; 	/**	 * Reference time for relative calculations	 *	 * This is used in place of `time()` when calculating Max-Age expiration and	 * checking time validity.	 *	 * @var int	 */	public $reference_time = 0; 	/**	 * Create a new cookie object	 *	 * @param string                                                  $name           The name of the cookie.	 * @param string                                                  $value          The value for the cookie.	 * @param array|\WpOrg\Requests\Utility\CaseInsensitiveDictionary $attributes Associative array of attribute data	 * @param array                                                   $flags          The flags for the cookie.	 *                                                                                Valid keys are `'creation'`, `'last-access'`,	 *                                                                                `'persistent'` and `'host-only'`.	 * @param int|null                                                $reference_time Reference time for relative calculations.	 *	 * @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $name argument is not a string.	 * @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $value argument is not a string.	 * @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $attributes argument is not an array or iterable object with array access.	 * @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $flags argument is not an array.	 * @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $reference_time argument is not an integer or null.	 */	public function __construct($name, $value, $attributes = [], $flags = [], $reference_time = null) {		if (is_string($name) === false) {			throw InvalidArgument::create(1, '$name', 'string', gettype($name));		} 		if (is_string($value) === false) {			throw InvalidArgument::create(2, '$value', 'string', gettype($value));		} 		if (InputValidator::has_array_access($attributes) === false || InputValidator::is_iterable($attributes) === false) {			throw InvalidArgument::create(3, '$attributes', 'array|ArrayAccess&Traversable', gettype($attributes));		} 		if (is_array($flags) === false) {			throw InvalidArgument::create(4, '$flags', 'array', gettype($flags));		} 		if ($reference_time !== null && is_int($reference_time) === false) {			throw InvalidArgument::create(5, '$reference_time', 'integer|null', gettype($reference_time));

Changelog

Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/Requests/src/Cookie.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.