Answer the question
In order to leave comments, you need to log in
Curl, instead of cookies, the path to the file with them is passed, what am I doing wrong?
<?php
$request = '
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache';
$split = explode("\n",$request);
if( $ch = curl_init() ) {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch,CURLOPT_URL,'http://localhost/viewcookie.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_COOKIE, $_SERVER['DOCUMENT_ROOT'].'/cookie1.txt');
curl_setopt($ch, CURLOPT_COOKIEJAR, $_SERVER['DOCUMENT_ROOT'].'/cookie1.txt');
curl_setopt ($ch, CURLOPT_HTTPHEADER,$split );
curl_setopt($ch, CURLOPT_ENCODING , 'gzip, deflate');
curl_setopt($ch, CURLOPT_POSTFIELDS,"log=adm&pwd=123");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (Windows; U; Windows NT 5.0; En; rv:1.8.0.2) Gecko/20070306 Firefox/1.0.0.4");
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_NOBODY,false);
curl_setopt($ch,CURLOPT_HEADER,true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
$out = curl_exec($ch);
echo "<b>".$out."</b>";
echo curl_getinfo($ch, CURLINFO_HEADER_OUT);
?>
curl_setopt($ch, CURLOPT_COOKIEJAR, $_SERVER['DOCUMENT_ROOT'].'/cookie1.txt');
curl_setopt($ch, CURLOPT_COOKIE, $_SERVER['DOCUMENT_ROOT'].'/cookie1.txt');
echo curl_getinfo($ch, CURLINFO_HEADER_OUT);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question