1############################################################################# 2# 3# Apache::Session::Serialize::UUEncode 4# Serializes session objects using Storable and pack 5# Copyright(c) 2000 Jeffrey William Baker (jwbaker@acm.org) 6# Distribute under the Perl License 7# 8############################################################################ 9 10package Apache::Session::Serialize::UUEncode; 11 12use strict; 13use vars qw($VERSION); 14use Storable qw(nfreeze thaw); 15 16$VERSION = '1.01'; 17 18sub serialize { 19 my $session = shift; 20 21 $session->{serialized} = pack("u", nfreeze($session->{data})); 22} 23 24sub unserialize { 25 my $session = shift; 26 27 my $data = thaw(unpack("u", $session->{serialized})); 28 die "Session could not be unserialized" unless defined $data; 29 #Storable can return undef or die for different errors 30 $session->{data} = $data; 31} 32 331; 34 35=pod 36 37=head1 NAME 38 39Apache::Session::Serialize::UUEncode - Use Storable and C<pack()> 40to zip up persistent data 41 42=head1 SYNOPSIS 43 44 use Apache::Session::Serialize::UUEncode; 45 46 $zipped = Apache::Session::Serialize::UUEncode::serialize($ref); 47 $ref = Apache::Session::Serialize::UUEncode::unserialize($zipped); 48 49=head1 DESCRIPTION 50 51This module fulfills the serialization interface of Apache::Session. It 52serializes the data in the session object by use of Storable's C<nfreeze()> and 53C<thaw()> functions, and Perl's C<pack()> and C<unpack()>. The serialized data 54is ASCII text, suitable for storage in backing stores that don't handle binary 55data gracefully, such as Postgres. 56 57=head1 AUTHOR 58 59This module was written by Jeffrey William Baker <jwbaker@acm.org>. 60 61=head1 SEE ALSO 62 63L<Apache::Session::Serialize::Storable>, L<Apache::Session::Serialize::Base64>, 64L<Apache::Session> 65