LWP::UserAgent and HTTP::Cookies
Matthew Hesher (hesher@cs.fsu.edu)
Wed, 18 Apr 2001 21:19:22 -0400 (EDT)
Can anyone tell me how to change LWP::UserAgents defautlt behavior from
'ignore cookeis' to 'get and set cookies'? I've written a little script
that looks like this:
$ua = LWP::UserAgent->new;
$cookie_jar = HTTP::Cookies->new;
$cookie_jar->clear();
$ua->cookie_jar($cookie_jar);
$request = HTTP::Request->new('GET',
'http://some.web-page.com/page1.asp');
$response = $ua->request($request);
print($cookie_jar->as_string());
$request = HTTP::Request->new('POST',
'http://some.web-page.com/page2.asp');
print($request->headers_as_string());
$response = $ua->request($request);
After the first request is fulfilled, the cookie-jar is filled with the
cookies received from page1.asp. I can see this from the first print
statement above. However, before sending the second message, print the
headers and get nothing. I've tried forcing the heads in there with
'$cookie_jar->add_cookie_header($request)' and if I print the header
after that, the $request header appears to be set with the cookie
received from page1.asp, but page2.asp (which is lookie for the cookie
from page1.asp) says it can't find the cookie. Can anyone help me
figure out what's going on. Please email me as I don't have newsgroup
access very often.
Curt Hesher
Curt Hesher
hesher@cs.fsu.edu