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

curl-and-php

Re: PHP cURL & session cookie

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 15 Oct 2001 09:45:25 +0200 (MET DST)

On Fri, 12 Oct 2001, Krzysztof Araszkiewicz wrote:

> $ch=curl_init('test.php/switch/form')
> curl_setopt( CURL_TIMEOUT, 120 );
> curl_setopt( CURL_RETURNTRANSFER, 0 );

^ These two lines are not correct, they must pass the curl handle as a first
argument, like the other curl_setopt() calls below...

> 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);
>
> Summary - I want to receive form content as XML, so translate form
> variables via form_manage and call test.php - simulate POST.

Well to start with, in your command line version you certainly did not call
the postfields 'form_xml' as you did up here.

> 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

How come you had to do two command line operations but only should us one
written in PHP? It was obviously not matching any of the command line
versions either.

Can't you just, slowly, try to make the command line versions into PHP step
by step?

Then if that doesn't work, show us the command lines again and the PHP code
you've written to "simulate" those command lines.

-- 
    Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
Received on 2001-10-15