symfony/http-foundation · error · LogicException

" " is already an instance of…

Error message

"%s" is already an instance of "SessionUpdateTimestampHandlerInterface", you cannot wrap it with "%s".

What it means

A LogicException thrown in StrictSessionHandler's constructor when the wrapped $handler already implements SessionUpdateTimestampHandlerInterface. StrictSessionHandler exists to add those timestamp/validate-id behaviors, so double-wrapping would duplicate them and corrupt session semantics; the offending input is the already-strict handler instance passed in.

Solutions

  1. Check ($handler instanceof \SessionUpdateTimestampHandlerInterface) before constructing and use the handler as-is
  2. Pass the underlying raw SessionHandlerInterface (e.g. NativeFileSessionHandler or \SessionHandler) instead of an already-strict wrapper
  3. Refactor wiring code so StrictSessionHandler is applied exactly once per handler chain
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at Session/Storage/Handler/StrictSessionHandler.php:27 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at Session/Storage/Handler/StrictSessionHandler.php:27

    public function __construct(
        private \SessionHandlerInterface $handler,
    ) {
        if ($handler instanceof \SessionUpdateTimestampHandlerInterface) {
            throw new \LogicException(\sprintf('"%s" is already an instance of "SessionUpdateTimestampHandlerInterface", you cannot wrap it with "%s".', get_debug_type($handler), self::class));
        }
    }

View on GitHub (pinned to 5aea19cd67)