On this page
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
$responsearray|WP_Error Required-
HTTP response.
$namestring Required-
The name of the cookie to retrieve.
Return
WP_Http_Cookie|string The WP_Http_Cookie object, or empty string if the cookie is not present in the response.
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 '';
}
Related
Uses
| Uses | Description |
|---|---|
| wp_remote_retrieve_cookies() wp-includes/http.php | Retrieve only the cookies from the raw response. |
Used By
| Used By | Description |
|---|---|
| wp_remote_retrieve_cookie_value() wp-includes/http.php | Retrieve a single cookie’s value by name from the raw response. |
Changelog
| Version | Description |
|---|---|
| 4.4.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_remote_retrieve_cookie