0

I want to use curl and post method then I want to get response header (not response source) like set-cookie etc
How can I do this? I created the below code but it only shows response source:

$ch = curl_init();

curl_setopt($ch, 
    CURLOPT_URL,"https://www.example.com");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS,$post);  //Post Fields
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, 1);

$server_output = curl_exec ($ch);

echo ($server_output);

I tried getinfo($ch);

Nic3500
  • 8,144
  • 10
  • 29
  • 40
HOLO
  • 1
  • 3
    Possible duplicate of [Can PHP cURL retrieve response headers AND body in a single request?](https://stackoverflow.com/questions/9183178/can-php-curl-retrieve-response-headers-and-body-in-a-single-request) – Amin.MasterkinG Apr 21 '19 at 10:03
  • Please show us the full code you tried. The `curl_setopt($ch, ` bit should make this code fail – YakovL Apr 21 '19 at 12:03

0 Answers0