nofw/session-handlers

Package providing various SessionHandlerInterface implementations

v0.2.0 2017-04-18 14:13 UTC

This package is auto-updated.

Last update: 2024-11-19 10:33:32 UTC


README

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.