homepage Welcome to WebmasterWorld Guest from 54.145.191.14
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
curl, browsers and cookies
turbohost

10+ Year Member



 
Msg#: 4036856 posted 11:18 am on Dec 4, 2009 (gmt 0)

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?

 

turbohost

10+ Year Member



 
Msg#: 4036856 posted 4:57 pm on Dec 4, 2009 (gmt 0)

someone ?

NomikOS

5+ Year Member



 
Msg#: 4036856 posted 5:08 pm on Dec 4, 2009 (gmt 0)

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);


NomikOS

5+ Year Member



 
Msg#: 4036856 posted 5:15 pm on Dec 4, 2009 (gmt 0)

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

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

etc...

turbohost

10+ Year Member



 
Msg#: 4036856 posted 9:35 pm on Dec 4, 2009 (gmt 0)

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved