wp_remote_retrieve_cookie_value() WordPress Function

The wp_remote_retrieve_cookie_value() function is used to get the value of a specific cookie from the response of an HTTP request. This is useful if you need to get a cookie value that is set by a third-party server.

wp_remote_retrieve_cookie_value( array|WP_Error $response, string $name ) #

Retrieve a single cookie’s value by name from the raw response.


Parameters

$response

(array|WP_Error)(Required)HTTP response.

$name

(string)(Required)The name of the cookie to retrieve.


Top ↑

Return

(string) The value of the cookie. Empty string if the cookie isn't present in the response.


Top ↑

Source

File: wp-includes/http.php

function wp_remote_retrieve_cookie_value( $response, $name ) {
	$cookie = wp_remote_retrieve_cookie( $response, $name );

	if ( ! is_a( $cookie, 'WP_Http_Cookie' ) ) {
		return '';
	}

	return $cookie->value;
}


Top ↑

Changelog

Changelog
VersionDescription
4.4.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.