advanced cURL problem ?
| From: | Joel Colombo | Date: | Tue, 22 Apr 2003 13:40:10 +0000 |
| Subject: | advanced cURL problem ? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-144816@lists.php.net to get a copy of this message | ||
I am curling a site that sets a session cookie.
When i enable cookie prompting in IE 6 it shows me the session cookie and
asks if i want it set.
but when i curl to the exact same URL it does not show up in the headers.
i also think i am using the cookie options correctly...
THIS CALL JUST HITS THE SITE TO SET A SESSION.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $original_URL_that starts_my session);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$curl_result = curl_exec($ch);
<< I parse the result looking for header cookie or whatever for session id
set it to $SID >>
THIS PIECE CALLS THE AREA REQUIRING THE SESSION TO BE SET (as you see i
attempt $SID)
$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_URL, $new_URL_that_requires_session);
curl_setopt($ch2, CURLOPT_POST, 1);
curl_setopt($ch2, CURLOPT_POSTFIELDS, $vars);
curl_setopt($ch2, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch2, CURLOPT_REFERER, 'somewhere.com');
curl_setopt($ch2, CURLOPT_COOKIE, "JSESSIONID=$SID");
curl_setopt($ch2, CURLOPT_COOKIEJAR, 'cookies.txt');
curl_setopt($ch2, CURLOPT_COOKIEFILE, 'cookies.txt');
curl_setopt($ch2, CURLOPT_VERBOSE, 1);
curl_setopt($ch2, CURLOPT_HEADER, 1);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch2, CURLOPT_FOLLOWLOCATION, 1);
$curl_result = curl_exec ($ch2);
Please could someone show me a curl method that retains or at least returns
them in the result ?
I cant get the session id to show up anywhere ? any suggestions that someone
has used to set session cookies ?
really i just need to retrieve the session cookie being set.
i have it working if i go to the page with my real browser. prompt for the
cookie variable to ask. grab the value from it there, then paste it to my
code (as $SID var) and run my script in the same window i just used to get
the sid. but i need to automate grabbing that SID from the first block.
Thanks,
Joel Colombo