File Coverage

blib/lib/Apache/Session/Serialize/Base64.pm
Criterion Covered Total %
statement 16 16 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 0 2 0.0
total 22 24 91.7


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