Package providing various SessionHandlerInterface implementations
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
spec
src
.editorconfig
.gitattributes
.gitignore
.scrutinizer.yml
.styleci.yml
.travis.yml
CHANGELOG.md
LICENSE
Makefile
README.md
composer.json
phpspec.ci.yml
phpspec.yml.dist

README.md

Session handlers

Latest Version Build Status Code Coverage Quality Score Total Downloads

Package providing various SessionHandlerInterface implementations.

Install

Via Composer

$ composer require nofw/session-handlers

Usage

This package provides three Session Handler implementations:

  • PSR-6
  • PSR-16
  • Doctrine Cache

Choose your backend and instantiate and register handler.

$cache = new ImaginaryCacheItemPool();
$handler = new \Nofw\Session\CacheSessionHandler($cache);

session_set_save_handler($handler);

Use your session as usual.

Logging

The SessionHandlerInterface does not allow throwing exceptions to indicate failure. Instead it expects the handler to return empty values (empty string or false). However, the PSR-X implementations do throw exceptions. To adhere the interface and to not lose the ability to detect failures, these implementations accept a PSR-3 logger as their second constructor argument and also implement the LoggerAwareInterface.

$cache = new ImaginaryCacheItemPool();
$logger = new Monolog\Logger('nofw')
$handler = new \Nofw\Session\CacheSessionHandler($cache, $logger);

The caught exceptions are logged as errors.

Testing

$ make test

Security

If you discover any security related issues, please contact us at mark.sagikazar@gmail.com.

License

The MIT License (MIT). Please see License File for more information.