"Fossies" - the Fresh Open Source Software Archive

Member "Apache-Session-1.93/lib/Apache/Session/Serialize/Base64.pm" (15 Sep 2009, 1809 Bytes) of package /linux/www/Apache-Session-1.93.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Base64.pm" see the Fossies "Dox" file reference documentation.

    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 use strict;
   13 use vars qw($VERSION);
   14 use MIME::Base64;
   15 use Storable qw(nfreeze thaw);
   16 
   17 $VERSION = '1.01';
   18 
   19 sub serialize {
   20     my $session = shift;
   21     
   22     $session->{serialized} = encode_base64(nfreeze($session->{data}));
   23 }
   24 
   25 sub unserialize {
   26     my $session = shift;
   27     
   28     my $data = thaw(decode_base64($session->{serialized}));
   29     die "Session could not be unserialized" unless defined $data;
   30     #Storable can return undef or die for different errors
   31     $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>