cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

PHP cURL & session cookie

From: Krzysztof Araszkiewicz <aras_at_panda.bg.univ.gda.pl>
Date: Fri, 12 Oct 2001 14:50:03 +0200 (METDST)

Hi all!
I have a problem with PHP cURL and session cookie. Let me explain:
I have two pages: test.php & form_manage.php

test.php
..check if user logged in
if( $switch=="form") {
global $form_xml;
..
.. manage form XML (save to session)
..
}
else {
.. show form (ACTION=/form_manage.php)
}

form_manage.php
..
..make a XML document from form data
..$xml contain filled form content as XML

$ch=curl_init('test.php/switch/form')
curl_setopt( CURL_TIMEOUT, 120 );
curl_setopt( CURL_RETURNTRANSFER, 0 );
curl_setopt ($ch, CURLOPT_COOKIE, session_name().'='.session_id() );
curl_setopt ($ch, CURLOPT_POST, 1 );
curl_setopt ($ch, CURLOPT_POSTFIELDS, "form_xml=".$xml );
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1 );
curl_exec ($ch);
curl_close ($ch);

test.php is called from index.php - after logging script

Summary - I want to receive form content as XML, so translate form
variables via form_manage and call test.php - simulate POST. When user(s)
fill form multiple times - I store user's form as array in session.
When I didn't set the CURL_COOKIE - after each form submit session was
cleared. Now - when uses fill the form and submit the script work > 300s.

When I work with command line curl all works OK
curl -m 120 -D /tmp/Header.txt -d login=xx pass=qwerty submit=submit
http://my.server.com/index.php
From file Header.txt I get session id and
curl -m 120 -b PHPID=<session_id_from_Header.txt> -d fname=xx lname=yy
submit=submit http://my.server.com/test.php > Page.html
This works fast and store forms as array in session
I don't know what mistake I make and what is the reason of working
difference about PHP and command line CURL

Thanks in advance...

Krzysztof Araszkiewicz

P.S. I'm sorry - my English is not good :((
Received on 2001-10-12