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

curl-and-php

Proxying cookies with curl

From: The Pope Of Chilli Town <baja_666_at_yahoo.com>
Date: Tue, 28 Oct 2003 14:39:47 -0800 (PST)

I'm working on a simple "proxy" using libCURL (it's a
sort of framework that integrates applications into a
website backend). It's easy enough to proxy POST and
GET data, but I'm stumbling over how to handle
cookies.

Essentially, what I want to do is set a local cookie
(or maybe a session var) that corresponds to any
cookies recieved or set by the proxied app. I can send
existing cookies with CURLOPT_COOKIE, but I'm getting
stuck on how to retrieve the cookies set by the
proxied app. I can see the cookie headers with
CURLOPT_HEADER, but they're sent with the output and
it's difficult to figure out where the headers end and
the content begins. (will explore this further if I
can't come up with a more concise solution)

Is there any way of collecting the cookies into an
array, or at least all headers into a string (so I can
parse out the cookie headers)? I've looked at
CURLOPT_COOKIEJAR, but I'm not sure if the overhead of
writing a file, reading it, and managing it for
multiple users would be worth the hassle.

I figured CURLOPT_WRITEHEADER might work with an
in-memory (or bufferable) file wrapper, like
php://output or php://stdout, but curl couldn't write
to the former, and I'm not sure how the latter could
be redirected to a variable or output, so I could
collect the data using output buffering.

Is there a feature of libcurl that I've missed? Is
there another approach to this beyond filtering
cookies out of the headers?

Thanks, I appreciate any input I can get on this.

__________________________________
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/

-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/
Received on 2003-10-28