Hi there, please if somebody can help me with a simple curl example, all i need is that the script to do the following: enter on a website - http://example.com/index.php get the cookies from that page save cookie to cookie.txt after that using the cookies enter on the http://exemple.com/newpage.php clear cookie from file. I will appreciate your help. Many Thanks
(Untested) <?php $cookie_file = 'cookies.txt'; $url_1 = 'http://example.com/index.php'; $url_2 = 'http://exemple.com/newpage.php'; $ch = curl_init($url_1); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // Go to first URL curl_exec($ch); curl_setopt($ch, CURLOPT_URL, $url_2); // Go to second curl_exec($ch); curl_close($ch); // Clear cookie file file_put_contents($cookie_file, null); ?> PHP:
First of all thank you for your help. Is not really what i'm looking but it is a start. On my home computer I have apache installed and every time when I open my browser I would like this script to open automatically the ebay page and log me in. I tried to modify this script for using ebay, but i receive an error that my browser is rejecting cookies. I found a script here: http://curl.haxx.se/libcurl/php/examples/ebay_login.html but it seems this in not working anymore, can you please take a look. Thanks Snix