input = $input; $this->session = $session; } /** * Validates the session * * @param boolean $restart Flag if the session should be restarted * * @return void * * @since 2.0.0 * @throws InvalidSessionException */ public function validate(bool $restart = false): void { if ($restart) { $this->session->set('session.client.address', null); } $remoteAddr = IpHelper::getIp(); // Check for client address if (!empty($remoteAddr) && filter_var($remoteAddr, FILTER_VALIDATE_IP) !== false) { $ip = $this->session->get('session.client.address'); if ($ip === null) { $this->session->set('session.client.address', $remoteAddr); } elseif ($remoteAddr !== $ip) { throw new InvalidSessionException('Invalid client IP'); } } } }