symfony/http-foundation · error · LogicException

The session handler " " does not support clearing all…

Error message

The session handler "%s" does not support clearing all sessions.

What it means

MarshallingSessionHandler::clear() clears all sessions, but only if the wrapped inner handler implements ClearableSessionHandlerInterface. Otherwise it throws LogicException naming the handler's debug type. This is a capability check: bulk clearing is optional for session handlers, so unsupported handlers are rejected rather than silently failing.

Solutions

  1. Wrap/replace the inner handler with one implementing ClearableSessionHandlerInterface
  2. Check `$handler instanceof ClearableSessionHandlerInterface` before calling clear() and handle the unsupported case (e.g. iterate and destroy session ids individually)
  3. Implement the interface on a custom inner handler
  4. Remove the clear() call or feature when the storage backend cannot bulk-clear

Example fix

// before
$marshallingHandler->clear(); // LogicException if inner handler not clearable
// after
if ($marshallingHandler instanceof ClearableSessionHandlerInterface || $innerHandler instanceof ClearableSessionHandlerInterface) {
    $marshallingHandler->clear();
} else {
    throw new UnsupportedSessionOperationException('Clearing all sessions is not supported by this handler.');
}
Defensive patterns

Strategy: type-guard

Validate before calling

if (!$innerHandler instanceof ClearableSessionHandlerInterface) {
    throw new LogicException(sprintf('Handler %s cannot clear all sessions; use a clearable handler or destroy sessions individually.', get_debug_type($innerHandler)));
}

Type guard

function isClearable(object $handler): bool
{
    return $handler instanceof ClearableSessionHandlerInterface;
}

Try / catch

try {
    $marshallingHandler->clear();
} catch (\LogicException $e) {
    if (str_contains($e->getMessage(), 'does not support clearing all sessions')) {
        // fallback: destroy known session ids or skip the bulk-clear feature
    } else {
        throw $e;
    }
}

Prevention

When it happens

Trigger: Calling MarshallingSessionHandler::clear() when the inner handler (e.g. PdoSessionHandler, MemcachedSessionHandler, or any plain \SessionHandler) does not implement ClearableSessionHandlerInterface.

Common situations: Wrapping a third-party or built-in session handler without a clear() capability and calling session-level 'clear all sessions' logic (e.g. admin 'log out all users' feature); upgrading code that assumed the inner handler was clearable.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of symfony/http-foundation@5aea19cd67 (2026-09-13). Data as JSON: /api/errors/9de386416ac62321. Report an issue: GitHub.

Appendix: source

Thrown at Session/Storage/Handler/MarshallingSessionHandler.php:94

    public function validateId(#[\SensitiveParameter] string $sessionId): bool
    {
        return $this->handler->validateId($sessionId);
    }

    public function updateTimestamp(#[\SensitiveParameter] string $sessionId, string $data): bool
    {
        return $this->handler->updateTimestamp($sessionId, $data);
    }

    public function clear(): void
    {
        if ($this->handler instanceof ClearableSessionHandlerInterface) {
            $this->handler->clear();

            return;
        }

        throw new \LogicException(\sprintf('The session handler "%s" does not support clearing all sessions.', get_debug_type($this->handler)));
    }
}

View on GitHub (pinned to 5aea19cd67)