Answer the question
In order to leave comments, you need to log in
How to get data from cookie.txt?
We all know that in order to use cookies in Curl, you need to use the following parameters
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
site.com FALSE / FALSE 1475762564 csrftoken efe1ce7900138db355aec682c44d21a5
Answer the question
In order to leave comments, you need to log in
public static function parsingCookieFile($cookieFile)
{
$handle = fopen($cookieFile, 'r');
for ($i = 0; $i < 4; $i++) {
if (!feof($handle)) {
fgets($handle);
}
}
$out = [];
while (!feof($handle)) {
$buffer = fgets($handle);
preg_match('/\tFALSE\t\/\tFALSE\t[0-9]+\t([^\t]*)\t(.*)/', $buffer, $found);
if (isset($found[1]) && isset($found[2])) {
$out[$found[1]] = $found[2];
}
}
fclose($handle);
return $out;
}
Make cookie.php instead of cookie.txt, and in it
return [
ваш массив
];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question