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
MigratingSessionHandler wraps a read/write handler and a write-only handler (used when migrating session storage). The clear() method wipes all sessions, but it can only do so if the current handler implements ClearableSessionHandlerInterface; otherwise it throws a LogicException naming the offending handler class.
Solutions
- Make the current handler implement Symfony\Component\HttpFoundation\Session\Storage\Handler\ClearableSessionHandlerInterface and add a clear(): void method.
- Replace the current handler with a built-in clearable handler (e.g. NativeFileSessionHandler, PdoSessionHandler, RedisSessionHandler where supported).
- Wrap the call in a LogicException guard and skip/fallback to per-session destroy when clear is unsupported.
- Upgrade the third-party session handler package to a version that implements ClearableSessionHandlerInterface.
Example fix
// before
class LegacyHandler implements \SessionHandlerInterface { /* no clear() */ }
$handler = new MigratingSessionHandler(new LegacyHandler(), new PdoSessionHandler($pdo));
$handler->clear(); // throws
// after
class LegacyHandler implements \SessionHandlerInterface, ClearableSessionHandlerInterface {
public function clear(): void { /* delete all sessions */ }
}
$handler = new MigratingSessionHandler(new LegacyHandler(), new PdoSessionHandler($pdo));
$handler->clear(); // works Defensive patterns
Strategy: try-catch
Validate before calling
if (!$currentHandler instanceof \Symfony\Component\HttpFoundation\Session\Storage\Handler\ClearableSessionHandlerInterface) {
throw new \LogicException('Handler does not support clear(); skip or migrate first.');
} Type guard
function isClearable($handler): bool {
return $handler instanceof \Symfony\Component\HttpFoundation\Session\Storage\Handler\ClearableSessionHandlerInterface;
} Try / catch
try {
$migratingHandler->clear();
} catch (\LogicException $e) {
// fall back to per-session destroy or log and skip
} Prevention
- Always implement ClearableSessionHandlerInterface in custom session handlers.
- Check the interface before calling clear() on wrapped handlers.
- Prefer built-in clearable handlers during migrations.
When it happens
Trigger: Calling MigratingSessionHandler::clear() when the current (read) handler does not implement ClearableSessionHandlerInterface, e.g. wrapping a legacy custom \SessionHandlerInterface handler that lacks a clear() method.
Common situations: Calling $session->clear() or invalidating all sessions while a migration is configured with a non-clearable legacy handler; custom handlers written before ClearableSessionHandlerInterface existed; third-party session handlers that never added clear().
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
- Invalid argument $savePath
- Failed to read session: INSERT reported a duplicate id but…
- The following options are not supported
- The "sameSite" parameter value is not valid.
- The cookie name " " uses a reserved prefix, which requires…
AI-assisted analysis of symfony/http-foundation@5aea19cd67 (2026-09-13).
Data as JSON: /api/errors/26c7a26ad84a1bde.
Report an issue: GitHub.
Appendix: source
Thrown at Session/Storage/Handler/MigratingSessionHandler.php:111
{
// No reading from new handler until switch-over
return $this->currentHandler->validateId($sessionId);
}
public function updateTimestamp(#[\SensitiveParameter] string $sessionId, string $sessionData): bool
{
$result = $this->currentHandler->updateTimestamp($sessionId, $sessionData);
$this->writeOnlyHandler->updateTimestamp($sessionId, $sessionData);
return $result;
}
public function clear(): void
{
if ($this->currentHandler instanceof ClearableSessionHandlerInterface) {
$this->currentHandler->clear();
} else {
throw new \LogicException(\sprintf('The session handler "%s" does not support clearing all sessions.', get_debug_type($this->currentHandler)));
}
if ($this->writeOnlyHandler instanceof ClearableSessionHandlerInterface) {
$this->writeOnlyHandler->clear();
}
}
}
View on GitHub (pinned to 5aea19cd67)