cookies = $cookies; $this->trackingConfig = $trackingConfig; } public function getPageViewTimestamp(): ?int { if (!$this->trackingConfig->isCookieTrackingEnabled()) { return null; } return $this->getTimestampCookie(self::COOKIE_NAME); } public function setPageViewTimestamp(int $timestamp): void { if (!$this->trackingConfig->isCookieTrackingEnabled()) { return; } $this->cookies->set( self::COOKIE_NAME, ['timestamp' => $timestamp], [ 'expires' => time() + self::COOKIE_EXPIRY, 'path' => '/', ] ); } private function getTimestampCookie(string $cookieName): ?int { $data = $this->cookies->get($cookieName); return is_array($data) && $data['timestamp'] ? (int)$data['timestamp'] : null; } }