perldoc > HTTP::Cookies

๐Ÿช NAME

HTTP::Cookies - HTTP cookie jars

๐Ÿš€ Quick Reference

Use CaseCommandDescription
๐Ÿ“ฆ Create a cookie jar$cookie_jar = HTTP::Cookies->new(file => '...', autosave => 1)Initialize a jar with optional file persistence and autosave
๐Ÿ”— Attach jar to LWP UserAgent$browser->cookie_jar($cookie_jar)Set the cookie jar for automatic cookie handling
๐Ÿ“ฅ Extract cookies from response$cookie_jar->extract_cookies($response)Parse Set-Cookie headers from an HTTP response
๐Ÿ“ค Add cookie header to request$cookie_jar->add_cookie_header($request)Insert appropriate Cookie header into outgoing request
๐Ÿ’พ Save cookies to file$cookie_jar->savePersist cookie state to disk
๐Ÿ“‚ Load cookies from file$cookie_jar->loadRestore cookie state from file
๐Ÿงน Clear all cookies$cookie_jar->clearEmpty the entire cookie jar
๐Ÿ” Get cookies for a URL%cookies = $cookie_jar->get_cookies($url)Retrieve cookies applicable to a given URL

๐Ÿท๏ธ VERSION

version 6.10

๐Ÿ“– SYNOPSIS

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

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

Or for an empty and temporary cookie jar:

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

๐Ÿ“– DESCRIPTION

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 <http://curl.haxx.se/rfc/cookie_spec.html> and Cookie Central <http://www.cookiecentral.com>. This module also implements the new style cookies described in RFC 2965 <https://tools.ietf.org/html/rfc2965>. 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.

โš ๏ธ LIMITATIONS

This module does not support Public Suffix <https://publicsuffix.org/> encouraged by a more recent standard, RFC 6265 <https://tools.ietf.org/html/rfc6265>.

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*.

๐Ÿ› ๏ธ METHODS

๐Ÿ”— SEE ALSO

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

๐Ÿ‘ค AUTHOR

Gisle Aas <gisle AT activestate.com>

๐Ÿ“œ COPYRIGHT AND LICENSE

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.

HTTP::Cookies
๐Ÿช NAME ๐Ÿš€ Quick Reference ๐Ÿท๏ธ VERSION ๐Ÿ“– SYNOPSIS ๐Ÿ“– DESCRIPTION โš ๏ธ LIMITATIONS ๐Ÿ› ๏ธ METHODS ๐Ÿ”— SEE ALSO ๐Ÿ‘ค AUTHOR ๐Ÿ“œ COPYRIGHT AND LICENSE

Generated by phpman v4.9.27 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-18 08:02 @216.73.216.114
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format

^_top_^