on 7/8/02 10:29 AM, [EMAIL PROTECTED] purportedly said:

> Hi,
> 
> I am testing a simple script to grab cookie. however
> there is only one line as "#LWP-Cookies-1.0" in the
> saved file. what's wrong?

You have to tell LWP to extract cookies. It doesn't do it automatically. You
need something like:

    $cookie_jar = HTTP::Cookies->new(file=>'t.txt',autosave=>1);
    $ua->cookie_jar( $cookie_jar );
    # code to get response...after response received:
    $cookie_jar->extract_cookies( $response );

The $ua->cookie_jar is *only* to have LWP automatically *send* cookies with
a request, not to extract them. This would be a nice feature though, IMHO.

> here is the script
> 
> use LWP::UserAgent;
> use HTTP::Cookies;
> $cookie = new HTTP::Cookies;
> $ua = new LWP::UserAgent;
> $ua->agent("Mozilla/4.7");
> 
> $ua->cookie_jar(HTTP::Cookies->new(file=>'t.txt',autosave=>1));
> 
> $base_url='http://fwcgames.yahoo.com/cocacola';
> my $response=$ua->request(new HTTP::Request 'GET' =>
> $base_url);
> unless ( $response->is_success ) {
> print "Error: " . $response->status_line .
> "\n";
> }
> 
> thanks!
> 
> James
> 
> __________________________________________________
> Do You Yahoo!?
> Sign up for SBC Yahoo! Dial - First Month Free
> http://sbc.yahoo.com
> 


Keary Suska
Esoteritech, Inc.
"Leveraging Open Source for a better Internet"

Reply via email to