4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
15 * Adds basic `SessionUpdateTimestampHandlerInterface` behaviors to another `SessionHandlerInterface`.
17 * @author Nicolas Grekas <p@tchwork.com>
19 class StrictSessionHandler extends AbstractSessionHandler
24 public function __construct(\SessionHandlerInterface $handler)
26 if ($handler instanceof \SessionUpdateTimestampHandlerInterface) {
27 throw new \LogicException(sprintf('"%s" is already an instance of "SessionUpdateTimestampHandlerInterface", you cannot wrap it with "%s".', \get_class($handler), self::class));
30 $this->handler = $handler;
36 public function open($savePath, $sessionName)
38 parent::open($savePath, $sessionName);
40 return $this->handler->open($savePath, $sessionName);
46 protected function doRead($sessionId)
48 return $this->handler->read($sessionId);
54 public function updateTimestamp($sessionId, $data)
56 return $this->write($sessionId, $data);
62 protected function doWrite($sessionId, $data)
64 return $this->handler->write($sessionId, $data);
70 public function destroy($sessionId)
72 $this->doDestroy = true;
73 $destroyed = parent::destroy($sessionId);
75 return $this->doDestroy ? $this->doDestroy($sessionId) : $destroyed;
81 protected function doDestroy($sessionId)
83 $this->doDestroy = false;
85 return $this->handler->destroy($sessionId);
91 public function close()
93 return $this->handler->close();
99 public function gc($maxlifetime)
101 return $this->handler->gc($maxlifetime);