NAME

WWW::Session::Storage::MySQL - MySQL storage for WWW::Session

DESCRIPTION

MySQL backend for WWW:Session

VERSION

Version 0.12

SYNOPSIS

This module is used for storring serialized WWW::Session objects in MySQL

Usage :

    use WWW::Session::Storage::MySQL;

    my $storage = WWW::Session::Storage::MySQL->new({ 
                                dbh => $dbh,
                                table => 'sessions',
                                fields => {
                                    sid => 'session_id',
                                    expires => 'expires',
                                    data => 'data'
                                }
                });
    ...
    
    $storage->save($session_id,$expires,$serialized_data);
    
    my $serialized_data = $storage->retrive($session_id);

The "fields" hasref contains the mapping of session internal data to the column names from MySQL. The keys are the session fields ("sid","expires" and "data") and must all be present.

The MySQL types of the columns should be :

  • sid => varchar(32)

  • expires => DATETIME or TIMESTAMP

  • data => text

SUBROUTINES/METHODS

new

Creates a new WWW::Session::Storage::MySQL object

This method accepts only one argument, a hashref that must contain the fallowing data:

  • dbh Database handle

  • table The name of the table where the sessions will be stored

  • fields A hash ref containing the falowing keys

    • sid The same of the database field which will store the session id

    • expires The same of the database field which will store the expiration time

    • data The name of the field where the session data will be stored

save

Stores the given information into the database

retrieve

Retrieves the informations for a session, verifies that it's not expired and returns the string containing the serialized data

delete

Completely removes the session data for the given session id

Private methods

_determine_expires_type

Tries to determine if the expires field is UnixTimestamp or DateTime

_reset_last_cleanup

Resets the last DB cleanup timer, forcing all expired sessions to be removed when the next session is retrieved

AUTHOR

Gligan Calin Horea, <gliganh at gmail.com>

BUGS

Please report any bugs or feature requests to bug-www-session at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-Session. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc WWW::Session::Storage::MySQL

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2012 Gligan Calin Horea.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.