HTTP/2 301
server: nginx
date: Sat, 11 Oct 2025 19:46:00 GMT
content-type: text/html; charset=UTF-8
x-olaf: ⛄
vary: accept, content-type
x-redirect-by: WordPress
location: https://developer.wordpress.org/reference/functions/wp_remote_retrieve_cookie/
x-frame-options: SAMEORIGIN
alt-svc: h3=":443"; ma=86400
x-nc: MISS ord 1
HTTP/2 200
server: nginx
date: Sat, 11 Oct 2025 19:46:01 GMT
content-type: text/html; charset=UTF-8
vary: Accept-Encoding
x-olaf: ⛄
vary: accept, content-type
link:
; rel="https://api.w.org/"
link:
; rel="alternate"; title="JSON"; type="application/json"
link: ; rel=shortlink
x-frame-options: SAMEORIGIN
content-encoding: gzip
alt-svc: h3=":443"; ma=86400
x-nc: MISS ord 1
wp_remote_retrieve_cookie() – Function | Developer.WordPress.org
wp_remote_retrieve_cookie( array|WP_Error $response, string $name ): WP_Http_Cookie|string
Retrieves a single cookie by name from the raw response.
$response
array|WP_ErrorrequiredHTTP response.
$name
stringrequiredThe name of the cookie to retrieve.
WP_Http_Cookie|string The WP_Http_Cookie
object, or empty string if the cookie is not present in the response.
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 '';
}
View all references View on Trac View on GitHub
Version | Description |
---|
4.4.0 | Introduced. |
User Contributed Notes