Answer the question
In order to leave comments, you need to log in
Why is the file not being created with CURLOPT_COOKIEJAR?
index.php:
<?php
$ch=curl_init("http://home.local/curlTest/cookieTest.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_COOKIE, 'curl_normal_cookie=1; curl_session_cookie=1');
curl_setopt($ch, CURLOPT_COOKIEJAR, "file.txt");
$html=curl_exec($ch);
curl_close($ch);
echo $html;
<?php
$cook=false;
if(isset($_COOKIE['curl_session_cookie']))
{
$cook=true;
echo "Сессионная кука есть\r\n";
}
if(isset($_COOKIE['curl_normal_cookie']))
{
$cook=true;
echo "Нормальная кука есть\r\n";
}
@setcookie('curl_session_cookie', 1);
@setcookie('curl_normal_cookie', 1);
if($cook)
{
echo "Есть куки";
}
else echo "Нет куки";
Answer the question
In order to leave comments, you need to log in
Immediately there can be 2 options:
1) the rights to write are not set on the current folder;
and
2) the current folder for saving cookies is not at all the one you expect)) I myself have repeatedly encountered this.
Try replacing
with
So that the cookie file will probably end up in the same folder as the script. Don't forget to check write permissions on this folder, of course)
SELECT SUM(inner.`red`) FROM (
SELECT `red` FROM abtest ORDER BY id DESC LIMIT 5
) as `inner`
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question