WordPress at a glance

wp_remote_retrieve_cookie() WP 1.0

Retrieve a single cookie by name from the raw response.

No Hooks.

Return

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

Usage

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

Code of wp_remote_retrieve_cookie: wp-includes/http.php VER 5.0.1

<?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
    Hello, !     Log In . Register