jayc89/php-sql-session-handler

This package is abandoned and no longer maintained. The author suggests using the https://github.com/jayc89/PHP-MySQL-Session-Handler package instead.
There is no license information available for the latest version (dev-master) of this package.

dev-master 2015-01-27 08:09 UTC

This package is not auto-updated.

Last update: 2019-02-20 18:14:48 UTC


README

#Deprecated, please use PHP-MySQL-Session-Handler

PHP SQL Session Handler

SQLSessionHandler is a PHP MySQL Session Handler written for use with PHP-MySQL-PDO-Database-Class

Installation

composer install jayc89/php-sql-session-handler

Configuration

CREATE TABLE `session_handler` (
    `id` varchar(255) NOT NULL,
    `data` mediumtext NOT NULL,
    `timestamp` int(255) NOT NULL,
    PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
require 'vendor/autoload.php';

$session = new SQLSessionHandler();

// add db data
$session->setDbDetails('localhost', 'username', 'password', 'database');
// OR alternatively send a MySQLi resource
// $db = new Db(); // https://github.com/jayc89/php-mysql-pdo-database-class
// $session->setDbConnection($db);

$session->setDbTable('session_handler');
session_set_save_handler(array($session, 'open'),
                         array($session, 'close'),
                         array($session, 'read'),
                         array($session, 'write'),
                         array($session, 'destroy'),
                         array($session, 'gc'));

register_shutdown_function('session_write_close');
session_start();

License

MIT

Free Software, Hell Yeah!

Credits

sprainr - https://github.com/sprain/PHP-MySQL-Session-Handler