HTTP: Add support for the host-only flag to Wp_Http_Cookie.

Props soulseekah.
Fixes #43231.

Built from https://develop.svn.wordpress.org/trunk@45135


git-svn-id: http://core.svn.wordpress.org/trunk@44944 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Gary Pendergast
2019-04-08 05:32:51 +00:00
parent a125989772
commit cbdffc4a1e
4 changed files with 25 additions and 14 deletions

View File

@@ -60,6 +60,14 @@ class WP_Http_Cookie {
*/
public $domain;
/**
* host-only flag.
*
* @since 5.2.0
* @var bool
*/
public $host_only;
/**
* Sets up this cookie object.
*
@@ -67,16 +75,18 @@ class WP_Http_Cookie {
* or a header string detailing it.
*
* @since 2.8.0
* @since 5.2.0 Added `host_only` to the `$data` parameter.
*
* @param string|array $data {
* Raw cookie data as header string or data array.
*
* @type string $name Cookie name.
* @type mixed $value Value. Should NOT already be urlencoded.
* @type string|int $expires Optional. Unix timestamp or formatted date. Default null.
* @type string $path Optional. Path. Default '/'.
* @type string $domain Optional. Domain. Default host of parsed $requested_url.
* @type int $port Optional. Port. Default null.
* @type string $name Cookie name.
* @type mixed $value Value. Should NOT already be urlencoded.
* @type string|int $expires Optional. Unix timestamp or formatted date. Default null.
* @type string $path Optional. Path. Default '/'.
* @type string $domain Optional. Domain. Default host of parsed $requested_url.
* @type int $port Optional. Port. Default null.
* @type bool $host_only Optional. host-only storage flag. Default true.
* }
* @param string $requested_url The URL which the cookie was set on, used for default $domain
* and $port values.
@@ -128,7 +138,7 @@ class WP_Http_Cookie {
}
// Set properties based directly on parameters.
foreach ( array( 'name', 'value', 'path', 'domain', 'port' ) as $field ) {
foreach ( array( 'name', 'value', 'path', 'domain', 'port', 'host_only' ) as $field ) {
if ( isset( $data[ $field ] ) ) {
$this->$field = $data[ $field ];
}