The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Apache::Cookie::Encrypted - Encrypted HTTP Cookies Class

SYNOPSIS

  use Apache::Cookie::Encrypted;
  my $cookie = Apache::Cookie::Encrypted->new($r, ...); 

DESCRIPTION

The Apache::Cookie::Encrypted module is a class derived from Apache::Cookie. It creates a cookie with its contents encrypted with Crypt::Blowfish.

METHODS

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.

new

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.

bake

This is the same bake method in Apache::Cookie.

    $cookie->bake;
parse

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

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.

as_string

Format the cookie object as a string:

    #same as $cookie->bake
    $r->err_headers_out->add("Set-Cookie" => $cookie->as_string);
name

Get or set the name of the cookie:

    my $name = $cookie->name;

    $cookie->name("Foo");
value

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.

domain

Get or set the domain for the cookie:

    my $domain = $cookie->domain;
    $cookie->domain(".cp.net");
path

Get or set the path for the cookie:

    my $path = $cookie->path;
    $cookie->path("/");
expires

Get or set the expire time for the cookie:

    my $expires = $cookie->expires;
    $cookie->expires("+3h");
secure

Get or set the secure flag for the cookie:

    my $secure = $cookie->secure;
    $cookie->secure(1);

SEE ALSO

Apache(3), Apache::Cookie(3), Apache::Request(3)

AUTHOR

Jamie Krasnoo<jkrasnoo@socal.rr.com>

CREDITS

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.