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.6


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   4464 use strict;
  1         2  
  1         26  
13 1     1   4 use vars qw($VERSION);
  1         1  
  1         30  
14 1     1   10 use MIME::Base64;
  1         1  
  1         48  
15 1     1   4 use Storable qw(nfreeze thaw);
  1         1  
  1         126  
16              
17             $VERSION = '1.00';
18              
19             sub serialize {
20 1     1 0 541 my $session = shift;
21            
22 1         4 $session->{serialized} = encode_base64(nfreeze($session->{data}));
23             }
24              
25             sub unserialize {
26 1     1 0 59 my $session = shift;
27            
28 1         5 $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 and C functions, and MIME::Base64's C
52             and C. 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 .
59              
60             =head1 SEE ALSO
61              
62             L, L