You don't tell me in what way it does not work. My mindreading capabilities are limited in range, and I'm currently busy influencing important worldwide decisions, so please excuse me that I don't snoop through your brain to find out the exact "not working" you mean.
The HTTP::Cookies documentation tells me that you should use its extract_cookies method on the text of the response and not on some hash you retrieved elsewhere.
So you will either have to craft a HTTP::Response out of your incoming CGI request, or manually transfer each cookie out of the hash you already have:
foreach $cookie (keys %cookies) {
# $cookie_jar->set_cookie($version, $key, $val, $path, $domain, $port,
# $path_spec, $secure, $maxage, $discard, \%rest)
$cookie_jar->set_cookie(1,
$cookie->name,$cookie->value,$cookie->path,$cookie->domain,
80,'',0,$cookie->expires,0,{});
};
I haven't tested that code, but it comes more or less directly from the documentation of CGI::Cookie and HTTP::Cookie. Also, again, look at how HTTP::Proxy does its thing. It does something quite similar to what you do, if you look closer at it. |