function curl($url='', $post='', $referer='')
{
$cl = curl_init();
curl_setopt($cl, CURLOPT_URL, $url);
curl_setopt($cl, CURLOPT_RETURNTRANSFER,1);
curl_setopt($cl, CURLOPT_HEADER,1);
curl_setopt($cl, CURLOPT_TIMEOUT, 5);
curl_setopt($cl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($cl, CURLOPT_USERAGENT, 'Opera/9.80 (Windows NT 6.1; U; ru) Presto/2.2.15 Version/10.10');
curl_setopt($cl, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($cl, CURLOPT_COOKIEFILE, 'cookie.txt');
if(!empty($post))
{
curl_setopt($cl, CURLOPT_POST, 1);
curl_setopt($cl, CURLOPT_POSTFIELDS, $post);
}
else
{
curl_setopt($cl, CURLOPT_POST, 0);
}
if(!empty($referer))
{
curl_setopt($cl, CURLOPT_REFERER, $referer);
}
else
{
curl_setopt($cl,CURLOPT_REFERER, 1);
}
$ex=curl_exec($cl);
echo curl_getinfo($cl);
curl_close($cl);
echo curl_error($cl);
return $ex;
}
echo curl('https://free-lance.ru/','login=***&passwd=****','https://free-lance.ru');
(Добавление)
если присвоить куки с другого соединения все нормально, авторизация проходит, если же использовать те что скрипт получает, авторизация не проходит, получаю не верные куки.