SEARCH
NEW RPMS
DIRECTORIES
ABOUT
FAQ
VARIOUS
BLOG

BotDetect - Real-Time Bot Detection API
 
 

MAN page from RedHat Other LWP.pm-5.48-2.i386.rpm

lib::HTTP::Cookies

Section: User Contributed Perl Documentation (3)
Updated: libwww-perl-5.48
Index 

NAME

HTTP::Cookies - Cookie storage and management 

SYNOPSIS

 use HTTP::Cookies; $cookie_jar = HTTP::Cookies->new;
 $cookie_jar->add_cookie_header($request); $cookie_jar->extract_cookies($response);
 

DESCRIPTION

Cookies are a general mechanism which server side connections can useto both store and retrieve information on the client side of theconnection. For more information about cookies refer to<URL:http://www.netscape.com/newsref/std/cookie_spec.html> and<URL:http://www.cookiecentral.com/>. This module also implements thenew style cookies described in draft-ietf-http-state-man-mec-08.txt.The two variants of cookies are supposed to be able to coexist happily.

Instances of the class HTTP::Cookies are able to store a collectionof Set-Cookie2: and Set-Cookie: headers and are able to use thisinformation to initialize Cookie-headers in HTTP::Request objects.The state of a HTTP::Cookies object can be saved in and restored fromfiles. 

METHODS

The following methods are provided:
$cookie_jar = HTTP::Cookies->new;
The constructor takes hash style parameters. The followingparameters are recognized:

  file:            name of the file to restore cookies from and save cookies to  autosave:        save during destruction (bool)  ignore_discard:  save even cookies that are requested to be discarded (bool)
Future parameters might include (not yet implemented):

  max_cookies               300  max_cookies_per_domain    20  max_cookie_size           4096
  no_cookies   list of domain names that we never return cookies to

$cookie_jar->add_cookie_header($request);
The add_cookie_header() method will set the appropriate Cookie:-headerfor the HTTP::Request object given as argument. The $request musthave a valid url attribute before this method is called.
$cookie_jar->extract_cookies($response);
The extract_cookies() method will look for Set-Cookie: andSet-Cookie2: headers in the HTTP::Response object passed asargument. Any of these headers that are found are used to updatethe state of the $cookie_jar.
$cookie_jar->set_cookie($version, $key, $val, $path, $domain, $port, $path_spec, $secure, $maxage, $discard, \%rest)
The set_cookie() method updates the state of the $cookie_jar. The$key, $val, $domain, $port and $path arguments are strings. The$path_spec, $secure, $discard arguments are boolean values. The $maxagevalue is a number indicating number of seconds that this cookie willlive. A value <= 0 will delete this cookie. %rest definesvarious other attributes like ``Comment'' and ``CommentURL''.
$cookie_jar->save( [$file] );
This method file saves the state of the $cookie_jar to a file.The state can then be restored later using the load() method. If afilename is not specified we will use the name specified duringconstruction. If the attribute ignore_discared is set, then wewill even save cookies that are marked to be discarded.

The default is to save a sequence of ``Set-Cookie3'' lines.``Set-Cookie3'' is a proprietary LWP format, not known to be compatiblewith any browser. The HTTP::Cookies::Netscape sub-class canbe used to save in a format compatible with Netscape.

$cookie_jar->load( [$file] );
This method reads the cookies from the file and adds them to the$cookie_jar. The file must be in the format written by the save()method.
$cookie_jar->revert;
This method empties the $cookie_jar and re-loads the $cookie_jarfrom the last save file.
$cookie_jar->clear( [$domain, [$path, [$key] ] ]);
Invoking this method without arguments will empty the whole$cookie_jar. If given a single argument only cookies belonging tothat domain will be removed. If given two arguments, cookiesbelonging to the specified path within that domain are removed. Ifgiven three arguments, then the cookie with the specified key, pathand domain is removed.
$cookie_jar->scan( \&callback );
The argument is a subroutine that will be invoked for each cookiestored in the $cookie_jar. The subroutine will be invoked withthe following arguments:

  0  version  1  key  2  val  3  path  4  domain  5  port  6  path_spec  7  secure  8  expires  9  discard 10  hash

$cookie_jar->as_string( [$skip_discard] );
The as_string() method will return the state of the $cookie_jarrepresented as a sequence of ``Set-Cookie3'' header lines separated by``\n''. If $skip_discard is TRUE, it will not return lines forcookies with the Discard attribute.
 

SUB CLASSES

We also provide a subclass called HTTP::Cookies::Netscape whichloads and saves Netscape compatible cookie files. Youshould be able to have LWP share Netscape's cookies by constructingyour $cookie_jar like this:

 $cookie_jar = HTTP::Cookies::Netscape->new(                   File     => "$ENV{HOME}/.netscape/cookies",                   AutoSave => 1,               );
Please note that the Netscape cookie file format is not able to storeall the information available in the Set-Cookie2 headers, so you willprobably loose some information if you save in this format. 

COPYRIGHT

Copyright 1997-1999 Gisle Aas

This library is free software; you can redistribute it and/ormodify it under the same terms as Perl itself.


 

Index

NAME
SYNOPSIS
DESCRIPTION
METHODS
SUB CLASSES
COPYRIGHT

This document was created byman2html,using the manual pages.
 
ICM Bot detect detector