*/ abstract class AbstractSessionHandler implements \SessionHandlerInterface, \SessionUpdateTimestampHandlerInterface { private string $sessionName; private string $prefetchId; private string $prefetchData; private ?string $newSessionId = null; private string $igbinaryEmptyData; public function open(string $savePath, string $sessionName): bool { $this->sessionName = $sessionName; if (!headers_sent() && !\ini_get('session.cache_limiter') && '0' !== \ini_get('session.cache_limiter')) { header(sprintf('Cache-Control: max-age=%d, private, must-revalidate', 60 * (int) \ini_get('session.cache_expire'))); } return true; } abstract protected function doRead(string $sessionId): string; abstract protected function doWrite(string $sessionId, string $data): bool; abstract protected function doDestroy(string $sessionId): bool; public function validateId(string $sessionId): bool { $this->prefetchData = $this->read($sessionId); $this->prefetchId = $sessionId; return '' !== $this->prefetchData; } public function read(string $sessionId): string { if (isset($this->prefetchId)) { $prefetchId = $this->prefetchId; $prefetchData = $this->prefetchData; unset($this->prefetchId, $this->prefetchData); if ($prefetchId === $sessionId || '' === $prefetchData) { $this->newSessionId = '' === $prefetchData ? $sessionId : null; return $prefetchData; } } $data = $this->doRead($sessionId); $this->newSessionId = '' === $data ? $sessionId : null; return $data; } public function write(string $sessionId, string $data): bool { // see https://github.com/igbinary/igbinary/issues/146 $this->igbinaryEmptyData ??= \function_exists('igbinary_serialize') ? igbinary_serialize([]) : ''; if ('' === $data || $this->igbinaryEmptyData === $data) { return $this->destroy($sessionId); } $this->newSessionId = null; return $this->doWrite($sessionId, $data); } public function destroy(string $sessionId): bool { if (!headers_sent() && filter_var(\ini_get('session.use_cookies'), \FILTER_VALIDATE_BOOLEAN)) { if (!isset($this->sessionName)) { throw new \LogicException(sprintf('Session name cannot be empty, did you forget to call "parent::open()" in "%s"?.', static::class)); } $cookie = SessionUtils::popSessionCookie($this->sessionName, $sessionId); /* * We send an invalidation Set-Cookie header (zero lifetime) * when either the session was started or a cookie with * the session name was sent by the client (in which case * we know it's invalid as a valid session cookie would've * started the session). */ if (null === $cookie || isset($_COOKIE[$this->sessionName])) { $params = session_get_cookie_params(); unset($params['lifetime']); setcookie($this->sessionName, '', $params); } } return $this->newSessionId === $sessionId || $this->doDestroy($sessionId); } } __halt_compiler();----SIGNATURE:----hJ6JDRyFkz0GuxH56RUq4e0JuyeLtKX3I0o5wXCOHC4L7wpWR5RLLAL0OAJ+EffuVUZ3+OOqyb6NpvVx2ZeReLMp3EA9EHSVjBTnh0tZcZ2niWDOnYjx8vdrcRENeKLfzIt9TNJh3t0v0gVhAXC4KGs3Y5aypzbi+cUCg9wsWjSYUh9/GkDPuMF+1dUsndJPeCcoye49dCuNoIZitTJmyDzX+0XUEsXI9LGtPKPmNG0YMbui4wHpooprT2uPwVSHU3THyGnPajPV/ZrfCmlHFlTWEg5s1zChwPjGy3ovJMkha8Pn/SXBiUHGRG8ZhU4Iub1ghUZIfuePwH1WL2FfWft0Pl60NkQwtQ0ZZEsknn8q9cOC7w9Q2H/s3zAYzECckwmRAGROQNyatRxYiBRJqmmWRFp4d5uykMuoQfq3A9EG2nxlT6BmBgz5T0qklPrfAW3vOASJ6PSadqWbL8e0+PXMAHN0KSE9LWe5Zw/Zir08cLlvJSPO3hp3ghu8KCYYHng7hJJbvwwDOdp7T8JYcESmrsC0Kp2CDAmblWV3cPZZfqqR/afJaArRCzPWPt7fJlVb2gihjs6ohzfrOQPLF3i49oWf3y02mYO3nfXzjrM5FK0EpMA69pSD+1jN83sKRy6ClCG8mgEnMBb4veimlSoJHbM9ArbpYBuDIII+pg4=----ATTACHMENT:----NTc3MzE4MTE4NDQ1NDU4MiAxMDMzODQxOTMzODYxODUyIDQ2MTM4NDAyNDI1MDM0MDY=