-3

I want to get the following data "PHPSESSID" from this script in a string:

<?php    
file_get_contents('https://www.bedandbreakfast.nl/?page=ajaxcb&do=updateBookingIntent&arrival=2015-08-22&departure=2015-08-23&src=booking_arrival');

$cookies = array();
foreach ($http_response_header as $hdr) {
    if (preg_match('/^Set-Cookie:\s*([^;]+)/', $hdr, $matches)) {
        parse_str($matches[1], $tmp);
        $cookies += $tmp;
    }
}
print_r($cookies);
?> 

I tried to run this script, only that wasn't working...

echo $cookies[PHPSESSID];
Jan Koekepan
  • 81
  • 1
  • 9

1 Answers1

0

This one works:

file_get_contents('https://www.bedandbreakfast.nl/?page=ajaxcb&do=updateBookingIntent&arrival=2015-08-22&departure=2015-08-23&src=booking_arrival');
foreach ($http_response_header as $header) {
    if (substr($header, 0, 21) == 'Set-Cookie: PHPSESSID') {
        preg_match('/=([a-z0-9]+);/', $header, $matches);
        $sessionId = $matches[1];
        echo $sessionId;
    }
}
Jeroen Flamman
  • 965
  • 6
  • 10