To send cookies with a cURL request in PHP, you can use the CURLOPT_COOKIE
option to specify the cookies you want to include in the request header. Here's an example:
// Cookies to send
$cookies = "cookie1=value1; cookie2=value2";
// Initialize cURL session
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, 'http://example.com');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIE, $cookies);
// Execute cURL request
$response = curl_exec($ch);
// Close cURL session
curl_close($ch);
// Handle response
echo $response;
In the above example, replace http://example.com
with the URL you want to send the request to, and update the cookie1=value1; cookie2=value2
string with the actual cookies you want to include.
By setting the CURLOPT_COOKIE
option with the cookies, cURL will include them in the request header when making the request.