123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <?php
- namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
- class MigratingSessionHandler implements \SessionHandlerInterface, \SessionUpdateTimestampHandlerInterface
- {
- private \SessionHandlerInterface&\SessionUpdateTimestampHandlerInterface $currentHandler;
- private \SessionHandlerInterface&\SessionUpdateTimestampHandlerInterface $writeOnlyHandler;
- public function __construct(\SessionHandlerInterface $currentHandler, \SessionHandlerInterface $writeOnlyHandler)
- {
- if (!$currentHandler instanceof \SessionUpdateTimestampHandlerInterface) {
- $currentHandler = new StrictSessionHandler($currentHandler);
- }
- if (!$writeOnlyHandler instanceof \SessionUpdateTimestampHandlerInterface) {
- $writeOnlyHandler = new StrictSessionHandler($writeOnlyHandler);
- }
- $this->currentHandler = $currentHandler;
- $this->writeOnlyHandler = $writeOnlyHandler;
- }
- public function close(): bool
- {
- $result = $this->currentHandler->close();
- $this->writeOnlyHandler->close();
- return $result;
- }
- public function destroy(#[\SensitiveParameter] string $sessionId): bool
- {
- $result = $this->currentHandler->destroy($sessionId);
- $this->writeOnlyHandler->destroy($sessionId);
- return $result;
- }
- public function gc(int $maxlifetime): int|false
- {
- $result = $this->currentHandler->gc($maxlifetime);
- $this->writeOnlyHandler->gc($maxlifetime);
- return $result;
- }
- public function open(string $savePath, string $sessionName): bool
- {
- $result = $this->currentHandler->open($savePath, $sessionName);
- $this->writeOnlyHandler->open($savePath, $sessionName);
- return $result;
- }
- public function read(#[\SensitiveParameter] string $sessionId): string
- {
-
- return $this->currentHandler->read($sessionId);
- }
- public function write(#[\SensitiveParameter] string $sessionId, string $sessionData): bool
- {
- $result = $this->currentHandler->write($sessionId, $sessionData);
- $this->writeOnlyHandler->write($sessionId, $sessionData);
- return $result;
- }
- public function validateId(#[\SensitiveParameter] string $sessionId): bool
- {
-
- return $this->currentHandler->validateId($sessionId);
- }
- public function updateTimestamp(#[\SensitiveParameter] string $sessionId, string $sessionData): bool
- {
- $result = $this->currentHandler->updateTimestamp($sessionId, $sessionData);
- $this->writeOnlyHandler->updateTimestamp($sessionId, $sessionData);
- return $result;
- }
- }
|