I can not deal with curl. You need to log in to the URL http://www.mysite.ru/login.php, get the cookie, and then pass the cookie to the script http://www.mysite.ru/some.php and show on the browser what the last script will give.

Show with an example, please, I do not catch up with a little how to get a cookie and transfer it to another script. Docks read, did not understand.

    1 answer 1

    And so, first you need to log in to the site http://mysite.ru/login.php and get cookies from there. This can be done like this:

    $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://mysite.ru/login.php'); //url curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt"); // отсюда будут читаться куки curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt"); // сюда будут писаться куки curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_USERAGENT, 'Test UA'); curl_setopt($ch, CURLOPT_POST, true); // указываем что будет отправляться POST запрос ( Если он нужен для авторизации на сайте, конечно). curl_setopt($ch, CURLOPT_POSTFIELDS, 'username=KryDos&password=qwerty'); $data = curl_exec($ch); curl_close($ch); 

    If the authorization was successful, then the cookie.txt file will store the cookies you want to send to http://www.mysite.ru/some.php.

    Now, by analogy, do this:

     $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://mysite.ru/some.php'); //url curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt"); // отсюда будут читаться куки curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt"); // сюда будут писаться куки curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_USERAGENT, 'Test UA'); $data = curl_exec($ch); curl_close($ch); 

    Now the $ data variable will be what the browser would return when accessing mysite.ru/some.php.

    • Ok, works. Strange, I logged in this way, but I thought that the cookies would be lost if I initialized another curl ... - Yoharny Babay