Sending Cookies to the Server via CURL in PHP

Using CURL, you can send cookies, creating the impression for the target site that the cookie was sent by a real browser. This is done using the CURLOPT_COOKIE option.

Let's set a cookie as an example with the name 'name' and the value 'john':

curl.php<?php
  curl_setopt($curl, CURLOPT_COOKIE, 'name=john');
?>

Multiple cookies are separated by a semicolon followed by a space:

curl.php<?php
  curl_setopt($curl, CURLOPT_COOKIE, 'name=john; login=admin');
?>
Задание 1

Send a request to the following page and get the result:

file.php<?php
  if (!empty($_COOKIE)) {
    echo json_encode($_COOKIE);
  } else {
    echo 'error';
  }
?>
Задание 2

Send a request to the following page and get the result:

file.php<div>
  <?php
    if (!empty($_COOKIE)) {
      echo $_COOKIE['num1'] + $_COOKIE['num2'];
    } else {
      echo 'error';
    }
  ?>
</div>