develooper Front page | perl.libwww | Postings from April 2001

LWP::UserAgent and HTTP::Cookies

Thread Next
From:
Matthew Hesher
Date:
April 18, 2001 18:19
Subject:
LWP::UserAgent and HTTP::Cookies
Message ID:
Pine.LNX.4.30.0104182116400.26584-100000@quake.cs.fsu.edu
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


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About