wp_remote_retrieve_cookie( array|WP_Error $response, string $name ): WP_Http_Cookie|string

Retrieve a single cookie 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

WP_Http_Cookie|string The WP_Http_Cookie object. Empty string if the cookie isn't present in the response.


Top ↑

Source

File: wp-includes/http.php. View all references

function wp_remote_retrieve_cookie( $response, $name ) {
	$cookies = wp_remote_retrieve_cookies( $response );

	if ( empty( $cookies ) ) {
		return '';
	}

	foreach ( $cookies as $cookie ) {
		if ( $cookie->name === $name ) {
			return $cookie;
		}
	}

	return '';
}


Top ↑

Changelog

Changelog
Version Description
4.4.0 Introduced.

Top ↑

User Contributed Notes

You must log in before being able to contribute a note or feedback.