
Apache2::WebApp::Plugin::Cookie - Plugin providing HTTP cookie methods

my $obj = $c->plugin('Cookie')->method( ... ); # Apache2::WebApp::Plugin::Cookie->method()
or
$c->plugin('Cookie')->method( ... );

Common methods for creating and manipulating web browser cookies.

This package is part of a larger distribution and was NOT intended to be used directly. In order for this plugin to work properly, the following packages must be installed:
Apache2::WebApp Apache2::WebApp::Plugin::Filters Params::Validate

From source:
$ tar xfz Apache2-WebApp-Plugin-Cookie-0.X.X.tar.gz $ perl MakeFile.PL PREFIX=~/path/to/custom/dir LIB=~/path/to/custom/lib $ make $ make test $ make install
Perl one liner using CPAN.pm:
$ perl -MCPAN -e 'install Apache2::WebApp::Plugin::Cookie'
Use of CPAN.pm in interactive mode:
$ perl -MCPAN -e shell cpan> install Apache2::WebApp::Plugin::Cookie cpan> quit
Just like the manual installation of Perl modules, the user may need root access during this process to insure write permission is allowed within the installation directory.

In order to set a browser cookie, you need to specify a valid hostname in your webapp.conf
[apache] domain = www.domain.com

Set a new browser cookie.
$c->plugin('Cookie')->set( $c, {
name => 'foo',
value => 'bar',
expires => '24h',
domain => 'www.domain.com', # optional
secure => 0,
});
Return the browser cookie value.
my $result = $c->plugin('Cookie')->get($name);
# bar is value of $result
Delete a browser cookie by name.
$c->plugin('Cookie')->delete( \%controller, $name );

package Example;
use strict;
use warnings;
sub _default {
my ( $self, $c ) = @_;
$c->plugin('Cookie')->set( $c, {
name => 'foo',
value => 'bar',
expires => '1h',
secure => 0,
});
$c->plugin('CGI')->redirect( $c, '/app/example/verify' );
}
sub verify {
my ( $self, $c ) = @_;
$c->request->content_type('text/html');
print $c->plugin('Cookie')->get('foo');
}
1;

Apache2::WebApp, Apache2::WebApp::Plugin, Apache2::Cookie

Marc S. Brooks, <mbrooks@cpan.org> - http://mbrooks.info

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