title: PHP Retrieve the headers of a response to a POST request a key-value pair
body: <p>I have this php scripts:</p>
  <pre><code>$url = &quot;https://mysite/web/session/authenticate&quot;;
  $data = array (
   'params' =&gt; 
   array (
     'db' =&gt; 'mydb',
     'login' =&gt; 'myuserid',
     'password' =&gt; 'myuserpwd',
   ),
  );
  
  $data = json_encode($data);
  $options = array(
   'http' =&gt; array(
     'header'  =&gt;    &quot;Content-Type: application/json\r\n&quot; 
                   . &quot;Content-Length: &quot; . strlen($data) . &quot;\r\n&quot;,
     'method'  =&gt; 'POST',
     'content' =&gt; $data,
   )
  );
  $context  = stream_context_create($options);
  $response = file_get_contents($url, false, $context);
  </code></pre>
  <p>From the server response I need to retrieve a key-value pair (set-cookie) contained in the headers.
  <a href="https://i.stack.imgur.com/8Py0E.jpg" rel="nofollow noreferrer">Response fron POSTMAN</a>
  How can I do?
  Thanks</p>