Apache::Session::Serialize::Storable - Use Storable to zip up persistent data


Apache-Session documentation Contained in the Apache-Session distribution.

Index


Code Index:

NAME

Top

Apache::Session::Serialize::Storable - Use Storable to zip up persistent data

SYNOPSIS

Top

 use Apache::Session::Serialize::Storable;

 $zipped = Apache::Session::Serialize::Storable::serialize($ref);
 $ref = Apache::Session::Serialize::Storable::unserialize($zipped);

DESCRIPTION

Top

This module fulfills the serialization interface of Apache::Session. It serializes the data in the session object by use of Storable's nfreeze() and thaw() functions. The result is a binary object ready for storage.

AUTHOR

Top

This module was written by Jeffrey William Baker <jwbaker@acm.org>.

SEE ALSO

Top

Apache::Session::Serialize::Base64, Apache::Session


Apache-Session documentation Contained in the Apache-Session distribution.

#############################################################################
#
# Apache::Session::Serialize::Storable
# Serializes session objects using Storable
# Copyright(c) 2000 Jeffrey William Baker (jwbaker@acm.org)
# Distribute under the Perl License
#
############################################################################

package Apache::Session::Serialize::Storable;

use strict;
use vars qw($VERSION);
use Storable qw(nfreeze thaw);

$VERSION = '1.01';

sub serialize {
    my $session = shift;
    
    $session->{serialized} = nfreeze $session->{data};
}

sub unserialize {
    my $session = shift;
    
    my $data = thaw $session->{serialized};
    die "Session could not be unserialized" unless defined $data;
    #Storable can return undef or die for different errors
    $session->{data} = $data;
}

1;