Title: Jar::before_redirect_check
Published: March 29, 2023
Last modified: November 8, 2023

---

# Jar::before_redirect_check( WpOrgRequestsResponse $response )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wporg-requests-cookie-jar/before_redirect_check/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/classes/wporg-requests-cookie-jar/before_redirect_check/?output_format=md#source)

[ Back to top](https://developer.wordpress.org/reference/classes/wporg-requests-cookie-jar/before_redirect_check/?output_format=md#wp--skip-link--target)

Parse all cookies from a response and attach them to the response

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wporg-requests-cookie-jar/before_redirect_check/?output_format=md#parameters)󠁿

 `$response`WpOrgRequestsResponserequired

Response as received.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wporg-requests-cookie-jar/before_redirect_check/?output_format=md#source)󠁿

    ```php
    public function before_redirect_check(Response $response) {
    	$url = $response->url;
    	if (!$url instanceof Iri) {
    		$url = new Iri($url);
    	}

    	$cookies           = Cookie::parse_from_headers($response->headers, $url);
    	$this->cookies     = array_merge($this->cookies, $cookies);
    	$response->cookies = $this;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/requests/src/cookie/jar.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/Requests/src/Cookie/Jar.php#L177)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/Requests/src/Cookie/Jar.php#L177-L186)

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwporg-requests-cookie-jar%2Fbefore_redirect_check%2F)
before being able to contribute a note or feedback.