Apache::Cookie - HTTP Cookies Class
use Apache::Cookie (); my $cookie = Apache::Cookie->new($r, ...);
The Apache::Cookie module is a Perl interface to the cookie routines in libapreq. The interface is based on Lincoln Stein's CGI::Cookie module.
This interface is identical the to CGI::Cookie interface with one exception noted below. Refer the to CGI::Cookie documentation while these docs are "under construction."
Just like CGI::Cookie::new, but requires an Apache request object:
my $cookie = Apache::Cookie->new($r, -name => 'foo', -value => 'bar', -expires => '+3M', -domain => '.capricorn.com', -path => '/cgi-bin/database', -secure => 1 );
Put cookie in the oven to bake. (Add a Set-Cookie header to the outgoing headers table.)
$cookie->bake;
This method parses the given string if present, otherwise, the incoming Cookie header:
my $cookies = $cookie->parse; #hash ref my %cookies = $cookie->parse; my %cookies = $cookie->parse($cookie_string);
Fetch and parse the incoming Cookie header:
my $cookies = Apache::Cookie->fetch; #hash ref my %cookies = Apache::Cookie->fetch;
Format the cookie object as a string:
#same as $cookie->bake $r->err_headers_out->add("Set-Cookie" => $cookie->as_string);
Get or set the name of the cookie:
my $name = $cookie->name; $cookie->name("Foo");
Get or set the values of the cookie:
my $value = $cookie->value; my @values = $cookie->value; $cookie->value("string"); $cookie->value(\@array);
Get or set the domain for the cookie:
my $domain = $cookie->domain; $cookie->domain(".cp.net");
Get or set the path for the cookie:
my $path = $cookie->path; $cookie->path("/");
Get or set the expire time for the cookie:
my $expires = $cookie->expires; $cookie->expires("+3h");
Get or set the secure flag for the cookie:
my $secure = $cookie->secure; $cookie->secure(1);
Apache(3), Apache::Request(3)
Doug MacEachern
2 POD Errors
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head2'
=back without =over
To install AxKit, copy and paste the appropriate command in to your terminal.
cpanm
cpanm AxKit
CPAN shell
perl -MCPAN -e shell install AxKit
For more information on module installation, please visit the detailed CPAN module installation guide.