doctor_moron has asked for the wisdom of the Perl Monks concerning the following question:


i have a litle script like this

use LWP::UserAgent; use HTTP::Cookies; use HTTP::Request::Common; use constant MONK_LOG=> 'http://www.perlmonks.org/index.pl'; $ua=LWP::UserAgent->new; $newagent= 'loginTOmonks/1.0 (' . $ua->agent .')'; $ua->agent($newagent); $ua->cookie_jar(HTTP::Cookies->new(file=>"lwpcookies.txt",autosave=>1) +); #$ua->cookie_jar(HTTP::Cookies->new()); $res=POST(MONK_LOG, Content=> [op=>'login', user=>'doctor_moron', pass +wd=>'mypasswd']); $res= $ua->request($res); print $res->status_line, "\n"; #the way i see cookies print $ua->cookie_jar->as_string();
Cookies saved in lwpcookies.txt, is that true ?
if yea why when i open that file i just can't see any words?
so i think lwpcookies.txt is unreadable format file and my question is how perl translate that unreadable format? with this code : "print $ua->cookie_jar->as_string();" ?

thanks

Replies are listed 'Best First'.
Re: another cookies question
by ikegami (Patriarch) on Sep 21, 2004 at 21:40 UTC

    Your code displays (on STDOUT as opposed to lwpcookies.txt):

    Set-Cookie3: userpass="ikegami%25encodedpasswd%25salt"; path="/"; domain="www.perlmonks.org"; path_spec; discard; version=0

    Note the "discard" flag. That means the cookie should only be used for as long as the browser isn't closed, and that it shouldn't be written to disk. LWP obeys that flag unless you add ignore_discard=>1 to the arguments passed to the HTTP::Cookies constructor. When I added ignore_discard=>1, the cookie showed up in lwpcookies.txt.

    Who else thought it might have been Acme::Bleached? *wink*

A reply falls below the community's threshold of quality. You may see it by logging in.