How can I make it so that if the qwe
value is found in cookies, then do not open the curl_setopt($ch, CURLOPT_COOKIEJAR, 'entry/cookies/test.txt');
. I haven't figured out how to do it yet...
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://site.ru');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLINFO_HEADER_OUT, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
curl_setopt($ch, CURLOPT_COOKIEFILE, '/cookies/test.txt');
curl_setopt($ch, CURLOPT_COOKIEJAR, '/cookies/test.txt');
$response = curl_exec($ch);
curl_close($ch);
preg_match_all('|Set-Cookie: (.*);|U', $headers, $parse_cookies);
if(isset($parse_cookies[1]) && !$parse_cookies[1]) {
preg_match_all('|Set-Cookie: (.*?)|U', $headers, $parse_cookies);
}
$cookies = implode(';', $parse_cookies[1]);
?>