romeoz / rock-session
A simple Session library for PHP
Installs: 1 331
Dependents: 5
Suggesters: 3
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=5.4.0
- romeoz/rock-events: 0.11.*
Requires (Dev)
- phpunit/phpunit: ^4.7.0
- romeoz/rock-cache: 0.15.*
- romeoz/rock-db: 0.15.*
- romeoz/rock-mongodb: 0.15.*
Suggests
- romeoz/rock-cache: required for MemorySession
- romeoz/rock-db: required for DbSession
- romeoz/rock-mongodb: required for MongoSession
This package is not auto-updated.
Last update: 2024-11-19 05:28:59 UTC
README
Handlers
Installation
From the Command Line:
composer require romeoz/rock-session
or in your composer.json:
{ "require": { "romeoz/rock-session": "*" } }
Quick Start
####Session as key-value memory storage
$config = [ 'cache' => new \rock\cache\Memcached ]; $session = new \rock\session\MemorySession($config); $session->add('name', 'Tom'); echo $session->get('name'); // result: Tom
####Session as MongoDB storage
$config = [ 'connection' => new \rock\mongodb\Connection ]; $session = new \rock\session\MongoSession($config); $session->add('name', 'Tom'); echo $session->get('name'); // result: Tom
Default is used the garbage collector (GC). You can use TTL indexes.
$connection = new \rock\mongodb\Connection; // Create TTL index $connection ->getCollection('session') ->createIndex('expire', ['expireAfterSeconds' => 0]); $config = [ 'connection' => $connection, 'useGC' => false ]; $session = new \rock\session\MongoSession($config); $session->add('name', 'Tom'); echo $session->get('name'); // result: Tom
Requirements
- PHP 5.4+
- For
MemorySession
required Rock Cache:composer require romeoz/rock-cache
- For
MongoSession
required Rock MongoDB:composer require romeoz/rock-mongodb
- For
DbSession
required Rock DB:composer require romeoz/rock-db
All unbolded dependencies is optional.
License
Session library is open-sourced software licensed under the MIT license.