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
I need help with curl...
Moderator: General Moderators
Yes I have tried.feyd wrote:We won't do your work for you. What have you tried so far?
Code: Select all
<?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']);
curl_exec($ch);
curl_setopt($ch, CURLOPT_URL, $url_2);
curl_exec($ch);
curl_close($ch);
file_put_contents($cookie_file, null);
?>Thanks
Snix
Last edited by Snix on Sat Nov 17, 2007 9:57 am, edited 1 time in total.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Dig through the user comments on http://php.net/curl_setopt, there are quite a few examples of sending to SSL enabled sites.
I've just made it... many thanks.Jcart wrote:Dig through the user comments on http://php.net/curl_setopt, there are quite a few examples of sending to SSL enabled sites.