WordPress at a glance

wp_remote_retrieve_cookie() WP 1.0

Retrieve a single cookie by name from the raw response.

Возвращает

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

No Hooks.

Usage

wp_remote_retrieve_cookie( $response, $name );
$response(array/WP_Error) (required)
HTTP response.
$name(string) (required)
The name of the cookie to retrieve.

Список изменений

С версии 4.4.0 Введена.

Code of wp_remote_retrieve_cookie() WP 5.5.1

wp-includes/http.php
<?php
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 '';
}

Related Functions

From tag: HTTP API (curl remote)

No comments
    Log In . Register