jamiecressey/php-mysql-session-handler
最新稳定版本:0.0.1
Composer 安装命令:
composer require jamiecressey/php-mysql-session-handler
包简介
MySQL PHP Session Handler
关键字:
README 文档
README
This repository contains a custom PHP session handler using MySQL as a backend. The class has been tested successfully using PHP-FPM and HHVM. To get started, it is recommended, although not required, this class is used in conjunction with PHP-MySQL-PDO-Database-Class.
How to Install
using Composer
Create a composer.json file in your project root:
{
"require": {
"jamiecressey/php-mysql-session-handler": "dev-master"
}
}
Then run the following composer command:
$ php composer.phar install
How to use
CREATE TABLE IF NOT EXISTS `sessions` ( `id` varchar(32) NOT NULL, `timestamp` int(10) unsigned DEFAULT NULL, `data` mediumtext, PRIMARY KEY (`id`), KEY `timestamp` (`timestamp`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
require 'vendor/autoload.php'; $handler = new \JamieCressey\SessionHandler\SessionHandler(); // Pass DB details to create a new MySQLi connection $handler->setDbDetails('localhost', 'username', 'password', 'database'); // OR alternatively, inject an existing MySQLi resource // $db = new Db(); // See: https://github.com/jamiecressey/php-mysql-pdo-database-class // $handler->setDbConnection($db); $handler->setDbConnection($db); $handler->setDbTable('sessions'); session_set_save_handler($handler, true); session_start();
Authors
License
MIT Public License
统计信息
- 总下载量: 874
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 14
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-10-08