Make WordPress Core


Ignore:
Timestamp:
08/17/2013 01:19:04 AM (12 years ago)
Author:
dd32
Message:

WP_HTTP: Cookies: When following redirects, include the request cookies in the redirected requests. Fixes #24987

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-http.php

    r25044 r25046  
    196196        }
    197197
    198         return $this->_dispatch_request($url, $r);
     198        $response = $this->_dispatch_request($url, $r);
     199
     200        // Append cookies that were used in this request to the response
     201        if ( ! empty( $r['cookies'] ) ) {
     202            $cookies_set = wp_list_pluck( $response['cookies'], 'name' );
     203            foreach ( $r['cookies'] as $cookie ) {
     204                    if ( ! in_array( $cookie->name, $cookies_set ) && $cookie->test( $url ) ) {
     205                                $response['cookies'][] = $cookie;
     206                    }
     207            }
     208        }
     209
     210        return $response;
    199211    }
    200212
     
    638650            if ( in_array( $response['response']['code'], array( 302, 303 ) ) )
    639651                $args['method'] = 'GET';
     652        }
     653
     654        // Include valid cookies in the redirect process
     655        if ( ! empty( $response['cookies'] ) ) {
     656            foreach ( $response['cookies'] as $cookie ) {
     657                if ( $cookie->test( $redirect_location ) )
     658                        $args['cookies'][] = $cookie;
     659            }
    640660        }
    641661
Note: See TracChangeset for help on using the changeset viewer.