HTTP::Cookies - HTTP cookie jars


version 6.10


use HTTP::Cookies;
$cookie_jar = HTTP::Cookies->new(
  file => "$ENV{'HOME'}/lwp_cookies.dat",
  autosave => 1,

use LWP;
my $browser = LWP::UserAgent->new;

Or for an empty and temporary cookie jar:

use LWP;
my $browser = LWP::UserAgent->new;
$browser->cookie_jar( {} );


This class is for objects that represent a "cookie jar" -- that is, a database of all the HTTP cookies that a given LWP::UserAgent object knows about.

Cookies are a general mechanism which server side connections can use to both store and retrieve information on the client side of the connection. For more information about cookies refer to Cookie Spec and Cookie Central. This module also implements the new style cookies described in RFC 2965. The two variants of cookies are supposed to be able to coexist happily.

Instances of the class HTTP::Cookies are able to store a collection of Set-Cookie2: and Set-Cookie: headers and are able to use this information to initialize Cookie-headers in HTTP::Request objects. The state of a HTTP::Cookies object can be saved in and restored from files.


This module does not support Public Suffix encouraged by a more recent standard, RFC 6265.

This module's shortcomings mean that a malicious Web site can set cookies to track your user agent across all sites under a top level domain. See t/publicsuffix.t in this module's distribution for details.

HTTP::CookieJar::LWP supports Public Suffix, but only provides a limited subset of this module's functionality and does not support standards older than RFC 6265.


The following methods are provided:


HTTP::Cookies::Netscape, HTTP::Cookies::Microsoft


Gisle Aas


This software is copyright (c) 2002 by Gisle Aas.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.