++ed by:
1 non-PAUSE user
Author image Gligan Calin Horea
and 1 contributors


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


MySQL backend for WWW:Session


Version 0.12


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'
    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



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


Stores the given information into the database


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


Completely removes the session data for the given session id

Private methods


Tries to determine if the expires field is UnixTimestamp or DateTime


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


Gligan Calin Horea, <gliganh at gmail.com>


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.


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

    perldoc WWW::Session::Storage::MySQL

You can also look for information at:



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.