for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Nofw\Session;
use Psr\Cache\CacheItemPoolInterface;
/**
* PSR-6 Session handler implementation.
*
* @author Márk Sági-Kazár <[email protected]>
*/
final class CacheSessionHandler implements \SessionHandlerInterface
{
* @var CacheItemPoolInterface
private $pool;
* @param CacheItemPoolInterface $pool
public function __construct(CacheItemPoolInterface $pool)
$this->pool = $pool;
}
* {@inheritdoc}
public function close()
return true;
public function destroy($session_id)
return $this->pool->deleteItem($session_id);
public function gc($maxlifetime)
public function open($save_path, $name)
public function read($session_id)
$item = $this->pool->getItem($session_id);
if ($item->isHit()) {
return $item->get();
return '';
public function write($session_id, $session_data)
$item->set($session_data);
return $this->pool->save($item);