nofw / session-handlers
Package providing various SessionHandlerInterface implementations
Requires
- php: ^7.0
- psr/log: ^1.0
Requires (Dev)
- doctrine/cache: ^1.5
- henrikbjorn/phpspec-code-coverage: ^3.0
- phpspec/phpspec: ^3.0
- psr/cache: ^1.0
- psr/simple-cache: ^1.0
Suggests
- psr/log-implementation: Log errors of the PSR-6 and PSR-16 implementations
This package is auto-updated.
Last update: 2024-11-19 10:33:32 UTC
README
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.