You'll find this page helpful:
http://uk2.php.net/manual/en/function.curl-setopt.php
In particular, check out CURLOPT_COOKIE
, CURLOPT_COOKIEFILE
, and CURLOPT_COOKIEJAR
.
You should be able to make 2 curl requests in the same php file, one that initiates the form (and grabs your session cookie then places it in your cookie file) and another that POSTS your request (using the same cookies).
Check out the comments further down that page for examples. You might also want to look at the paypal curl examples floating around the web, they do pretty much what you're after.