#Deprecated, please use PHP-MySQL-Session-Handler
SQLSessionHandler is a PHP MySQL Session Handler written for use with PHP-MySQL-PDO-Database-Class
composer install jayc89/php-sql-session-handler
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();
MIT
Free Software, Hell Yeah!
sprainr - https://github.com/sprain/PHP-MySQL-Session-Handler