wp_remote_retrieve_cookie_value

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

Description

(string) wp_remote_retrieve_cookie_value( (array) $response, (string) $name ); 

Returns (string)

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

Parameters (2)

0. $response (array)
HTTP response.
1. $name (string)
The name of the cookie to retrieve.

Usage

  1. if ( !function_exists( 'wp_remote_retrieve_cookie_value' ) ) { 
  2. require_once ABSPATH . WPINC . '/http.php'; 
  3.  
  4. // HTTP response. 
  5. $response = array(); 
  6.  
  7. // The name of the cookie to retrieve. 
  8. $name = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wp_remote_retrieve_cookie_value($response, $name); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/http.php  
  1. function wp_remote_retrieve_cookie_value( $response, $name ) { 
  2. $cookie = wp_remote_retrieve_cookie( $response, $name ); 
  3.  
  4. if ( ! is_a( $cookie, 'WP_Http_Cookie' ) ) { 
  5. return ''; 
  6.  
  7. return $cookie->value;