Apache-iNcom

 view release on metacpan or  search on metacpan

lib/Apache/Session/DBIBase64Store.pm  view on Meta::CPAN

    if ( $self->{dbh} ) {
	# Close connection to the database if we opened
	# it. If it is not ours, it is up to the owner
	# to dispose of it.
	$self->{dbh}->disconnect;
    }
}

1;
__END__

=pod

=head1 NAME

Apache::Session::DBIBase64Store - Session persistence via DBI with  ASCII 
encoding of session data.

=head1 SYNOPSIS

    package MySession;

    use Apache::Session;
    use Apache::Session::DBIBase64Store;
    use Apache::Session::NullLocker;

    @ISA = ( Apache::Session );

    sub get_object_store {
	my $self = shift;

	return new Apache::Session::DBIBase64Store $self;
    }

    sub get_lock_manager {
	my $self = shift;

	return new Apache::Session::NullLocker $self;
    }

=head1 DESCRIPTION

Apache::Session::DBIBase64Store is a session data persistent store for
L<Apache::Session|Apache::Session>. This module should be used instead
of DBIStore in database that don't support binary data in table fields
(like PostgreSQL for instance).

This store also store the creation time of the session and the timestamp
of the last update.

=head1 SCHEMA

This modules expect a table created with the following schema :

    CREATE TABLE sessions (
	id	    CHAR(32) PRIMARY KEY,
	length	    INT,
	a_session   TEXT,
	created	    TIMESTAMP DEFAULT 'now()',
	last_update TIMESTAMP DEFAULT 'now()'
	locked_by   INT
    );


The previous SQL statement is valid for PostgreSQL. Adapt for your
specific DBMS.

NOTE: The id length can be fine tuned for specific application. By
default, L<Apache::Session|Apache::Session> uses 16 char length ID,
but I usually use 128 bits ID (32 chars).

=head1 CONFIGURATION

This package can either use an already open DBH handle or it can
be told the DataSource, UserName and Password to open its own database
connection.

In the first case use something like this (using the
L<SYNOPSIS|/SYNOPSIS> example):

    my $dbh = DBI->connect( $DSN, $USER, $PASSWORD, { AutoCommit => 0,
						      RaiseError => 1,} );
    tie %sesssion, 'MySession', undef, { dbh => $dbh };

In the second case use something like this :

    tie %session, 'MySession', undef, { DataSource => $DSN,
					UserName   => $USERNAME,
					Password   => $PASSWORD,
    				        };

In the case where you give this module a DBH handle to use, rather
than to manage its own. The module will commit the transaction after
each insert, update or delete. Be warned if you are not using
AutoCommit mode.

=head1 CREDITS

This module is largely based on
L<Apache::Session::DBIStore|Apache::Session::DBIStore> by Jeffrey
William Baker (jeffrey@kathyandjeffrey.net).

=head1 AUTHOR

Copyright (c) 1999 Francis J. Lacoste and iNsu Innovations Inc.
All rights reserved.

Parts Copyright (c) 1998,1999 Jeffrey William Baker
(jeffrey@kathyandjeffrey.net)

This program is free software; you can redistribute it and/or modify
it under the terms as perl itself.

=head1 SEE ALSO

Apache::Session(3) Apache::Session::DBIStore(3) DBI(3)

=cut




( run in 1.955 second using v1.01-cache-2.11-cpan-302cb4679cc )