Следите за новинками
в нашем Telegram канале. Жми, чтобы подписаться:)
⊗ppSpCrCS 36 of 83 menu
◀ ▶

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':

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

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

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

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

<?php if (!empty($_COOKIE)) { echo json_encode($_COOKIE); } else { echo 'error'; } ?>

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

<div> <?php if (!empty($_COOKIE)) { echo $_COOKIE['num1'] + $_COOKIE['num2']; } else { echo 'error'; } ?> </div>
← →
↑
English▼
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline