jayc89/php-sql-session-handler

此软件包已被废弃,不再维护。作者建议使用https://github.com/jayc89/PHP-MySQL-Session-Handler软件包。
关于此软件包最新版本(dev-master)没有可用的许可证信息。

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

This package is not auto-updated.

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


README

#已废弃,请使用PHP-MySQL-Session-Handler

PHP SQL Session Handler

SQLSessionHandler是一个针对PHP-MySQL-PDO-Database-Class编写的PHP MySQL Session Handler

安装

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

自由软件,太棒了!

鸣谢

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