phalcon/incubator-session
最新稳定版本:v3.0.0
Composer 安装命令:
composer require phalcon/incubator-session
包简介
Phalcon Incubator Sessions Adapters
README 文档
README
Issues tracker
https://github.com/phalcon/incubator/issues
Database
This adapter uses a database backend to store session data:
use Phalcon\Db\Adapter\Pdo\Mysql; use Phalcon\Incubator\Session\Adapter\Database; $di->set('session', function () { // Create a connection $connection = new Mysql([ 'host' => 'localhost', 'username' => 'root', 'password' => 'secret', 'dbname' => 'test', ]); $session = new Database($connection, 'session_data'); $session->start(); return $session; });
This adapter uses the following table to store the data:
CREATE TABLE `session_data` ( `session_id` VARCHAR(35) NOT NULL, `data` text NOT NULL, `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, `modified_at` TIMESTAMP NULL DEFAULT NULL, PRIMARY KEY (`session_id`) );
Upgrading from phalcon/incubator 3.4 will require changes to the session_data table:
ALTER TABLE session_data MODIFY COLUMN created_at TIMESTAMP DEFAULT current_timestamp() NOT NULL;
ALTER TABLE session_data MODIFY COLUMN modified_at TIMESTAMP DEFAULT NULL NULL;
Mongo
Install PHP MongoDB Extension via pecl:
pecl install mongodb
After install, add the following line to your php.ini file:
extension=mongodb.so
This adapter uses a Mongo database backend to store session data:
use Phalcon\Incubator\Session\Adapter\Mongo as MongoSession; $di->set('session', function () { // Create a connection to mongo $mongo = new \MongoDB\Client( 'mongodb+srv://<username>:<password>@<cluster-address>/test?retryWrites=true&w=majority' ); // Passing a collection to the adapter $session = new MongoSession([ 'collection' => $mongo->test->session_data, ]); $session->start(); return $session; });
统计信息
- 总下载量: 286.62k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2020-05-24