"Fossies" - the Fresh Open Source Software Archive

Member "Apache-Session-1.93/lib/Apache/Session/MySQL.pm" (15 Sep 2009, 2296 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 "MySQL.pm" see the Fossies "Dox" file reference documentation.

    1 #############################################################################
    2 #
    3 # Apache::Session::MySQL
    4 # Apache persistent user sessions in a MySQL database
    5 # Copyright(c) 1998, 1999, 2000 Jeffrey William Baker (jwbaker@acm.org)
    6 # Distribute under the Perl License
    7 #
    8 ############################################################################
    9 
   10 package Apache::Session::MySQL;
   11 
   12 use strict;
   13 use vars qw(@ISA $VERSION);
   14 
   15 $VERSION = '1.01';
   16 @ISA = qw(Apache::Session);
   17 
   18 use Apache::Session;
   19 use Apache::Session::Lock::MySQL;
   20 use Apache::Session::Store::MySQL;
   21 use Apache::Session::Generate::MD5;
   22 use Apache::Session::Serialize::Storable;
   23 
   24 sub populate {
   25     my $self = shift;
   26 
   27     $self->{object_store} = new Apache::Session::Store::MySQL $self;
   28     $self->{lock_manager} = new Apache::Session::Lock::MySQL $self;
   29     $self->{generate}     = \&Apache::Session::Generate::MD5::generate;
   30     $self->{validate}     = \&Apache::Session::Generate::MD5::validate;
   31     $self->{serialize}    = \&Apache::Session::Serialize::Storable::serialize;
   32     $self->{unserialize}  = \&Apache::Session::Serialize::Storable::unserialize;
   33 
   34     return $self;
   35 }
   36 
   37 1;
   38 
   39 
   40 =pod
   41 
   42 =head1 NAME
   43 
   44 Apache::Session::MySQL - An implementation of Apache::Session
   45 
   46 =head1 SYNOPSIS
   47 
   48  use Apache::Session::MySQL;
   49 
   50  #if you want Apache::Session to open new DB handles:
   51 
   52  tie %hash, 'Apache::Session::MySQL', $id, {
   53     DataSource => 'dbi:mysql:sessions',
   54     UserName   => $db_user,
   55     Password   => $db_pass,
   56     LockDataSource => 'dbi:mysql:sessions',
   57     LockUserName   => $db_user,
   58     LockPassword   => $db_pass
   59  };
   60 
   61  #or, if your handles are already opened:
   62 
   63  tie %hash, 'Apache::Session::MySQL', $id, {
   64     Handle     => $dbh,
   65     LockHandle => $dbh
   66  };
   67 
   68 =head1 DESCRIPTION
   69 
   70 This module is an implementation of Apache::Session.  It uses the MySQL backing
   71 store and the MySQL locking scheme.  See the example, and the documentation for
   72 Apache::Session::Store::MySQL and Apache::Session::Lock::MySQL for more
   73 details.
   74 
   75 =head1 AUTHOR
   76 
   77 This module was written by Jeffrey William Baker <jwbaker@acm.org>.
   78 
   79 =head1 SEE ALSO
   80 
   81 L<Apache::Session::File>, L<Apache::Session::Flex>,
   82 L<Apache::Session::DB_File>, L<Apache::Session::Postgres>, L<Apache::Session>