Apache::Cookie::Encrypted - Encrypted HTTP Cookies Class
use Apache::Cookie::Encrypted; my $cookie = Apache::Cookie::Encrypted->new($r, ...);
The Apache::Cookie::Encrypted module is a class derived from Apache::Cookie. It creates a cookie with its contents encrypted with Crypt::Blowfish.
This interface is identical to the Apache::Cookie interface with a couple of exceptions. Refer to the Apache::Cookie documentation while these docs are being refined.
You'll notice that the documentation is pretty much the same as Apache::Cookie's. It is. I took most of the documentation and put it here for your convienience.
Just like Apache::Cookie->new(), it also requires an Apache object but also can take an Apache::Request object:
my $cookie = Apache::Cookie::Encrypted->new($r, -key => $key, -name => 'foo', -value => 'bar', -expires => '+3M', -domain => '.myeboard.com', -path => '/', -secure => 1 );
The key doesn't have to be defined in the constructor if you set it in your httpd.conf as a PerlSetVar.
PerlSetVar COOKIE_KEY <Blowfish key>
Make sure you do define a key or else the module will croak.
This is the same bake method in Apache::Cookie.
$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 incoming Cookie header:
my $cookies = Apache::Cookie::Encrypted->fetch; # hash ref my %cookies = Apache::Cookie::Encrypted->fetch; # plain hash
The value will be decrypted upon call to $cookie->value.
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 @value = $cookie->value; $cookie->value("string"); $cookie->value(\@array);
Just like in Apache::Cookie except that the contents are encrypted and decrypted automaticaly with the key defined in the constructor or set within httpd.conf as a PerlSetVar.
Remember the key must be set in the constructor or in the httpd.conf file for this module to work. It wil complain if its not set.
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::Cookie(3), Apache::Request(3)
Jamie Krasnoo<jkrasnoo@socal.rr.com>
Apache::Cookie - docs and modules - Doug MacEachern Crypt::CBC - Lincoln Stein, lstein@cshl.org Crypt::Blowfish - Dave Paris <amused@pobox.com> and those mentioned in the module.
To install Apache::Cookie::Encrypted, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Apache::Cookie::Encrypted
CPAN shell
perl -MCPAN -e shell install Apache::Cookie::Encrypted
For more information on module installation, please visit the detailed CPAN module installation guide.