{
    "content": [
        {
            "type": "text",
            "text": "# HTTP::Cookies (perldoc)\n\n**Summary:** HTTP::Cookies - HTTP cookie jars\n\n**Synopsis:** use HTTP::Cookies;\n$cookiejar = HTTP::Cookies->new(\nfile => \"$ENV{'HOME'}/lwpcookies.dat\",\nautosave => 1,\n);\nuse LWP;\nmy $browser = LWP::UserAgent->new;\n$browser->cookiejar($cookiejar);\nOr for an empty and temporary cookie jar:\nuse LWP;\nmy $browser = LWP::UserAgent->new;\n$browser->cookiejar( {} );\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **VERSION** (2 lines)\n- **SYNOPSIS** (16 lines)\n- **DESCRIPTION** (19 lines)\n- **LIMITATIONS** (12 lines)\n- **METHODS** (119 lines)\n- **SEE ALSO** (2 lines)\n- **AUTHOR** (2 lines)\n- **COPYRIGHT AND LICENSE** (5 lines)\n\n## Full Content\n\n### NAME\n\nHTTP::Cookies - HTTP cookie jars\n\n### VERSION\n\nversion 6.10\n\n### SYNOPSIS\n\nuse HTTP::Cookies;\n$cookiejar = HTTP::Cookies->new(\nfile => \"$ENV{'HOME'}/lwpcookies.dat\",\nautosave => 1,\n);\n\nuse LWP;\nmy $browser = LWP::UserAgent->new;\n$browser->cookiejar($cookiejar);\n\nOr for an empty and temporary cookie jar:\n\nuse LWP;\nmy $browser = LWP::UserAgent->new;\n$browser->cookiejar( {} );\n\n### DESCRIPTION\n\nThis class is for objects that represent a \"cookie jar\" -- that is, a\ndatabase of all the HTTP cookies that a given LWP::UserAgent object\nknows about.\n\nCookies are a general mechanism which server side connections can use to\nboth store and retrieve information on the client side of the\nconnection. For more information about cookies refer to Cookie Spec\n<http://curl.haxx.se/rfc/cookiespec.html> and Cookie Central\n<http://www.cookiecentral.com>. This module also implements the new\nstyle cookies described in RFC 2965\n<https://tools.ietf.org/html/rfc2965>. The two variants of cookies are\nsupposed to be able to coexist happily.\n\nInstances of the class *HTTP::Cookies* are able to store a collection of\nSet-Cookie2: and Set-Cookie: headers and are able to use this\ninformation to initialize Cookie-headers in *HTTP::Request* objects. The\nstate of a *HTTP::Cookies* object can be saved in and restored from\nfiles.\n\n### LIMITATIONS\n\nThis module does not support Public Suffix <https://publicsuffix.org/>\nencouraged by a more recent standard, RFC 6265\n<https://tools.ietf.org/html/rfc6265>.\n\nThis module's shortcomings mean that a malicious Web site can set\ncookies to track your user agent across all sites under a top level\ndomain. See t/publicsuffix.t in this module's distribution for details.\n\nHTTP::CookieJar::LWP supports Public Suffix, but only provides a limited\nsubset of this module's functionality and does not support standards\nolder than *RFC 6265*.\n\n### METHODS\n\nThe following methods are provided:\n\n$cookiejar = HTTP::Cookies->new\nThe constructor takes hash style parameters. The following\nparameters are recognized:\n\nfile:            name of the file to restore cookies from and save cookies to\nautosave:        save during destruction (bool)\nignorediscard:  save even cookies that are requested to be discarded (bool)\nhidecookie2:    do not add Cookie2 header to requests\n\nFuture parameters might include (not yet implemented):\n\nmaxcookies               300\nmaxcookiesperdomain    20\nmaxcookiesize           4096\n\nnocookies   list of domain names that we never return cookies to\n\n$cookiejar->getcookies( $urlordomain )\n$cookiejar->getcookies( $urlordomain, $cookiekey,... )\nReturns a hash of the cookies that applies to the given URL. If a\ndomainname is given as argument, then a prefix of \"https://\" is\nassumed.\n\nIf one or more $cookiekey parameters are provided return the given\nvalues, or \"undef\" if the cookie isn't available.\n\n$cookiejar->addcookieheader( $request )\nThe addcookieheader() method will set the appropriate\nCookie:-header for the *HTTP::Request* object given as argument. The\n$request must have a valid url attribute before this method is\ncalled.\n\n$cookiejar->extractcookies( $response )\nThe extractcookies() method will look for Set-Cookie: and\nSet-Cookie2: headers in the *HTTP::Response* object passed as\nargument. Any of these headers that are found are used to update the\nstate of the $cookiejar.\n\n$cookiejar->setcookie( $version, $key, $val, $path, $domain, $port,\n$pathspec, $secure, $maxage, $discard, \\%rest )\nThe setcookie() method updates the state of the $cookiejar. The\n$key, $val, $domain, $port and $path arguments are strings. The\n$pathspec, $secure, $discard arguments are boolean values. The\n$maxage value is a number indicating number of seconds that this\ncookie will live. A value of $maxage <= 0 will delete this cookie.\nThe $version argument sets the version of the cookie; the default\nvalue is 0 ( original Netscape spec ). Setting $version to another\nvalue indicates the RFC to which the cookie conforms (e.g. version 1\nfor RFC 2109). %rest defines various other attributes like \"Comment\"\nand \"CommentURL\".\n\n$cookiejar->save\n$cookiejar->save( $file )\n$cookiejar->save( file => $file, ignorediscard => $ignorediscard )\nThis method file saves the state of the $cookiejar to a file. The\nstate can then be restored later using the load() method. If a\nfilename is not specified we will use the name specified during\nconstruction. If the $ignorediscard value is true (or not\nspecified, but attribute *ignorediscard* was set at cookie jar\nconstruction), then we will even save cookies that are marked to be\ndiscarded.\n\nThe default is to save a sequence of \"Set-Cookie3\" lines.\n\"Set-Cookie3\" is a proprietary LWP format, not known to be\ncompatible with any browser. The *HTTP::Cookies::Netscape* sub-class\ncan be used to save in a format compatible with Netscape.\n\n$cookiejar->load\n$cookiejar->load( $file )\nThis method reads the cookies from the file and adds them to the\n$cookiejar. The file must be in the format written by the save()\nmethod.\n\n$cookiejar->revert\nThis method empties the $cookiejar and re-loads the $cookiejar\nfrom the last save file.\n\n$cookiejar->clear\n$cookiejar->clear( $domain )\n$cookiejar->clear( $domain, $path )\n$cookiejar->clear( $domain, $path, $key )\nInvoking this method without arguments will empty the whole\n$cookiejar. If given a single argument only cookies belonging to\nthat domain will be removed. If given two arguments, cookies\nbelonging to the specified path within that domain are removed. If\ngiven three arguments, then the cookie with the specified key, path\nand domain is removed.\n\n$cookiejar->cleartemporarycookies\nDiscard all temporary cookies. Scans for all cookies in the jar with\neither no expire field or a true \"discard\" flag. To be called when\nthe user agent shuts down according to RFC 2965.\n\n$cookiejar->scan( \\&callback )\nThe argument is a subroutine that will be invoked for each cookie\nstored in the $cookiejar. The subroutine will be invoked with the\nfollowing arguments:\n\n0  version\n1  key\n2  val\n3  path\n4  domain\n5  port\n6  pathspec\n7  secure\n8  expires\n9  discard\n10  hash\n\n$cookiejar->asstring\n$cookiejar->asstring( $skipdiscardables )\nThe asstring() method will return the state of the $cookiejar\nrepresented as a sequence of \"Set-Cookie3\" header lines separated by\n\"\\n\". If $skipdiscardables is TRUE, it will not return lines for\ncookies with the *Discard* attribute.\n\n### SEE ALSO\n\nHTTP::Cookies::Netscape, HTTP::Cookies::Microsoft\n\n### AUTHOR\n\nGisle Aas <gisle@activestate.com>\n\n### COPYRIGHT AND LICENSE\n\nThis software is copyright (c) 2002 by Gisle Aas.\n\nThis is free software; you can redistribute it and/or modify it under\nthe same terms as the Perl 5 programming language system itself.\n\n"
        }
    ],
    "structuredContent": {
        "command": "HTTP::Cookies",
        "section": "",
        "mode": "perldoc",
        "summary": "HTTP::Cookies - HTTP cookie jars",
        "synopsis": "use HTTP::Cookies;\n$cookiejar = HTTP::Cookies->new(\nfile => \"$ENV{'HOME'}/lwpcookies.dat\",\nautosave => 1,\n);\nuse LWP;\nmy $browser = LWP::UserAgent->new;\n$browser->cookiejar($cookiejar);\nOr for an empty and temporary cookie jar:\nuse LWP;\nmy $browser = LWP::UserAgent->new;\n$browser->cookiejar( {} );",
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "VERSION",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 16,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 19,
                "subsections": []
            },
            {
                "name": "LIMITATIONS",
                "lines": 12,
                "subsections": []
            },
            {
                "name": "METHODS",
                "lines": 119,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "COPYRIGHT AND LICENSE",
                "lines": 5,
                "subsections": []
            }
        ]
    }
}