Answer the question
In order to leave comments, you need to log in
How CURL works in PHP - how to send and receive cookies correctly?
Hello uv. forum users!
I've come across a problem that I can't solve yet and I hope for your tips.
I'll start over.
Wrote a script:
<?php
$url_first='http://www.sitename.ru/1.html';
$url_second = 'http://www.sitename.ru/2.html';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url_first); // set url to post to
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s
curl_setopt($ch, CURLOPT_POST, 1); // set POST method
curl_setopt($ch, CURLOPT_COOKIEJAR, '1.txt'); // сохранять информацию Cookie в файл
$result = curl_exec($ch); // run the whole process
//echo $result;
curl_setopt ($ch, CURLOPT_REFERER, $url_first); // Напоминаем серверу откуда пришли
curl_setopt ($ch, CURLOPT_URL, $url_second); // set url to post to
curl_setopt ($ch, CURLOPT_COOKIEFILE, '1.txt'); //Отправляем серверу куки
$result = curl_exec($ch); // run the whole process
echo $result;
curl_close($ch);
?>
# Netscape HTTP Cookie File
# curl.haxx.se/rfc/cookie_spec.html
# This file was generated by libcurl! Edit at your own risk.
.sitename.com TRUE / FALSE 0 PHPSESSID plpidr5mv0bbltphrp015s7214
Name: __auc
Content: ff023206150a8c346db68bc768b
Domain: .sitename.ru
Path: /
Send to: Any connections
Available for script: Yes
Created: Tuesday, October 27, 2015 12:06:21 PM
Expires: Thursday, October 27, 2016, 13:06:21
----------------------
Name: __asc
Content: ff023206150a8c346db68bc768b
Domain: .sitename.ru
Path: /
Send to: Any connections
Available to script: Yes
Created: Tue, Oct 27, 2015 12:06:21 PM
Expires: Tue, Oct 27, 2015 12:36:21 PM
etc.
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