onesimus-systems / ossession
PHP应用程序的集中式会话管理。
1.0.2
2017-01-23 19:37 UTC
Requires
- onesimus-systems/seed-catalog: ^1.1.0
Requires (Dev)
- phpunit/phpunit: 4.7.*
This package is auto-updated.
Last update: 2024-09-09 04:18:33 UTC
README
OSSession提供了一个集中式、数据库支持的PHP会话管理器。它需要最少的设置,并提供了一种可靠且简单的方式来管理PHP会话。
要求
- PHP >= 5.4.0
使用方法
use \Onesimus\Session\SessionManager // First we need to register the session handler $pdo = new PDO(...); $options = [ 'timeout' => 6 // hours 'gclotto' => [1, 100] // Chances a garbage collection will occur 'table' => 'sessions' // Database table that houses the session data. It must have three fields called 'id', 'data', and 'last_accessed'. 'last_accessed' is an int as times are stored in Unix time. ]; SessionManager::register($pdo, $options); SessionManager::startSession('php-session-name'); // Manipulate session data SessionManager::set('userid', 2); SessionManager::get('themename', 'default'); // get will either return the session value if it exists or whatever is passed as the second argument. By default it will return null if the session data doesn't exist. SessionManager::clear(); // Clear a session
许可
OSSession在BSD 3-clause许可下发布。许可文本可以在LICENSE.md中找到。