public static function isValid(string $name, string $token): bool
    {
        $savedToken = Session::get($name, null, self::$namespace);
        if (isset($savedToken['token'])) {
            if (time() >= $savedToken['time'] + $savedToken['lifetime']) {
                $savedToken['token'] = '';
            }
            return $token === $savedToken['token'];
        }
        return false;
    }