Is it possible to receive the cookies set by the remote server when doing a file_get_contents request?
I need php to do a http request, store the cookies, and then make a second http request using the stored cookies.
Is it possible to receive the cookies set by the remote server when doing a file_get_contents request?
I need php to do a http request, store the cookies, and then make a second http request using the stored cookies.
There's a shorter option using preg_grep:
$cookiesArray = preg_grep('/^Set-Cookie/i', $http_response_header);
This is gonna return an array with the Set-Cookie headers, then you'll have to get the cookie from each header, as the cookie header can include the path and some other flags.