Front page | perl.libwww |
Postings from March 2003
From: Sean M. Burke
March 3, 2003 19:03
Message ID: email@example.com
At 04:13 AM 2003-03-03 +0200, Hytham Shehab wrote:
> am haveing trouble setting up my cookies using this module, and
>particularly i don't understand how to use the set and scan routines.
>if anyone can point me to a good tutorial i will be greatfull.
All I've ever needed to know about cookies is in here:
A default LWP::UserAgent object acts like a browser with its cookies
support turned off. There are various ways of turning it on, by setting
its cookie_jar attribute. A "cookie jar" is an object representing a
little database of all the HTTP cookies that a browser can know about.
It can correspond to a file on disk (the way Netscape uses its
cookies.txt file), or it can be just an in-memory object that starts out
empty, and whose collection of cookies will disappear once the program
is finished running.
To give a browser an in-memory empty cookie jar, you set its cookie_jar
attribute like so:
To give it a copy that will be read from a file on disk, and will be
saved to it when the program is finished running, set the cookie_jar
attribute like this:
'file' => '/some/where/cookies.lwp',
# where to read/write cookies
'autosave' => 1,
# save it to disk when done
That file will be an LWP-specific format. If you want to be access the
cookies in your Netscape cookies file, you can use the
# yes, loads HTTP::Cookies::Netscape too
'file' => 'c:/Program Files/Netscape/Users/DIR-NAME-HERE/cookies.txt',
# where to read cookies
You could add an 'autosave' => 1 line as further above, but at time of
writing, it's uncertain whether Netscape might discard some of the
cookies you could be writing back to disk.
Sean M. Burke http://search.cpan.org/~sburke/