PHP - отправка cookie с file_get_contents

Пример в руководстве по PHP показывает, как вы можете использовать контексты потока для отправки cookie. Вот отрывок:

// Create a stream
$opts = array(
  'http'=>array(
    'method'=>"GET",
    'header'=>"Accept-language: en\r\n" .
              "Cookie: foo=bar\r\n"
  )
);

$context = stream_context_create($opts);

// Open the file using the HTTP headers set above
$file = file_get_contents('http://www.example.com/', false, $context);

Как отправить более одного файла cookie? Например, №1 или №2, или что-то еще?

№1

"Cookie: user=3345&pass=abcd\r\n"

№2

"Cookie: user=3345\r\n" . 
"Cookie: pass=abcd\r\n"
40
задан Majid Fouladpour 2 November 2015 в 22:22
поделиться