Here is the code:
$ch = curl_init('http://site.com/indexNew.php'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "user=test&password=test"); curl_setopt($ch, CURLOPT_REFERER, "http://pworlds.ru/"); curl_setopt($ch, CURLOPT_COOKIEJAR, "my_cookies.txt"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_exec($ch); curl_close($ch);
In theory, we send the request http://site.com/indexNew.php?user=test&password=test, while storing the cookie in my_cookies.txt.
How to do this: first send a request to http://site.com/indexNew.php?user=test&password=test, and then go to http://site.com/test.php, but at the same time cookies should not be lost ( page is available only to authorized users).
Thank you in advance.