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