Welcome to WebmasterWorld Guest from 107.22.87.205

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

curl, browsers and cookies

     
11:18 am on Dec 4, 2009 (gmt 0)

10+ Year Member



Hey guys,

I'll try to explain my problem ;-)

Curl is running via XAMPP on my portable. I use curl to logon to a site and I echo back the data in my browser screen (also on my portable). I have to add some extra info to the form fields in this webpage but when I click the submit button on this webpage I get the logon page again (which was already covered via curl). I use the curl/browser combination because it saves me a lot of time and I can't automate the full process (because it's way too complex).

The problem is that the cookie is stored in another file than the cookie file used by my browser. Is there a way to let curl use the cookie file of my standard browser? Or should I copy the curl cookie file to the standard browser cookie file? As far as I know I have to use sqlite to add a cookie to the standard browser's cookie file, but I think curl does not support sqlite yet?!

Anyone having experience with this problem?

4:57 pm on Dec 4, 2009 (gmt 0)

10+ Year Member



someone ?
5:08 pm on Dec 4, 2009 (gmt 0)

10+ Year Member



play with this code:

$cookie_file = PATH . 'cookies.txt'; /* chmod 0777 PATH . 'cookies.txt' */ 
$url = 'miUrl';

$process = curl_init($url);
curl_setopt($process, CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($process, CURLOPT_COOKIEJAR, $cookie_file);

5:15 pm on Dec 4, 2009 (gmt 0)

10+ Year Member



Obviously you must wrap this code properly... To check errors add:

$return = curl_exec($process);
if($return === false)
{
die(curl_error($process));
}

etc...

9:35 pm on Dec 4, 2009 (gmt 0)

10+ Year Member



I already have that piece of the script. It's the switch between curl and my standard browser that doesn't work because the cookie is set for curl and not for my browser. That's why I'm looking to copy the cookies from the curl cookie file to the standard browser's cookie file.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month