NAME
CGI::CookieSerial - a wrapper for creating serialized cookies with Data::Serializer and CGI::Cookie
SYNOPSIS
Setting a cookie with data: #!/usr/bin/perl
use strict;
use CGI;
use CGI::CookieSerial;
my $cgi = new CGI;
my $pbscookie = new CGI::CookieSerial(
-name => 'ticklemeelmo',
);
my @data = (
{
'to' => 'di',
'froo' => 'ti',
actor => 'Steve Martin',
food => 3.14,
},
'apple',
24,
);
$pbscookie->burn(\@data);
print $cgi->header({
-type => 'text/html',
});
Retrieving a cookie with data:
use strict;
use Data::Dumper;
use CGI;
use CGI::CookieSerial;
my $cgi = new CGI;
my $pbscookie = new CGI::CookieSerial(
-name => 'ticklemeelmo',
);
my @data = @{$pbscookie->cool()};
print $cgi->header({ -type => 'text/html', });
print "<html><body><pre>";
print Dumper(@data)."<br>";
print "$data[2]<br>";
print "$data[0]{actor}";
print "</body></html>";
ABSTRACT
Although deceptively similar to the workings of CGI::Cookie, this module
operates a little differently. By design, it is very simple to use. In
essence, one need only instantiate a new object and name the cookie,
create the data, and burn the cookie. Retrieval is just as simple.
DESCRIPTION
Stub documentation for CGI::CookieSerial, created by h2xs. It looks like the author of the extension was negligent enough to leave the stub unedited.
Blah blah blah.
METHONDS
new()
This is shamelessly copied from CGI::Cookie (more or less); it takes all the same parameters as CGI::Cookie. In addition to the CGI::Cookie->new() parameters, new() also takes the same parameters as Data::Serializer->new(). This gives the following list of parameters:
-name
-value
-expires
-domain
-path
-secure
and
-serializer
-digester
-cipher
-secret
-portable
-compress
-serializer_token
burn()
This method takes a parameter that is a reference to the data you want to store in the cookie. It serializes it and then sends the header. Only call this method when you are ready to set the cookie header.
cool()
This method returns the value of the cookie, either a stings or a reference (depending on what you stored).
eat()
This method simply prints the value of the cookie. There's really not a great deal of use for this method, despite the name, unless you are debugging.
TODO
Implement this with inheritance Not require that data be a reference, and have the module intelligently check and then Do The Right Thing
SEE ALSO
CGI, CGI::Cookie, Data::Serializer
AUTHOR
Duncan McGreggor, <oubiwann at cpan dot org>
COPYRIGHT AND LICENSE
Copyright 2003 by Duncan McGreggor
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.