symfony/http-foundation · error · InvalidArgumentException
The following options are not supported
Error message
The following options are not supported "%s".
What it means
MemcachedSessionHandler's constructor accepts only the options 'prefix', 'expiretime', and 'ttl'. Passing any other option key throws InvalidArgumentException listing the unsupported keys. This fails fast so a typoed or legacy option (e.g. 'expiretime' vs 'lifetime') does not silently misconfigure the session store.
Solutions
- Remove unsupported keys from the options array; keep only 'prefix', 'expiretime', and/or 'ttl'
- Fix the option name typo (compare against ['prefix','expiretime','ttl'])
- If configuring via framework bundle config, check the reference for your installed version — valid option names changed historically ('expiretime' vs 'lifetime')
- Set memcached server connection options on the \Memcached client itself, not in the handler options array
Example fix
// before $handler = new MemcachedSessionHandler($memcached, ['prefix' => 'sess_', 'lifetime' => 3600]); // after $handler = new MemcachedSessionHandler($memcached, ['prefix' => 'sess_', 'expiretime' => 3600]);
Defensive patterns
Strategy: validation
Validate before calling
$allowed = ['prefix', 'expiretime', 'ttl'];
$diff = array_diff(array_keys($options), $allowed);
if ($diff) {
throw new InvalidArgumentException('Unsupported MemcachedSessionHandler options: ' . implode(', ', $diff));
} Try / catch
try {
$handler = new MemcachedSessionHandler($memcached, $options);
} catch (\InvalidArgumentException $e) {
// log and correct the config: keep only 'prefix', 'expiretime', 'ttl'
} Prevention
- Whitelist config keys against ['prefix','expiretime','ttl'] before constructing the handler
- Do not copy option arrays between Redis/Memcached/PDO session handlers
- Consult the reference for your installed library version — option names changed historically
- Put connection-level settings on the \Memcached client, not in handler options
When it happens
Trigger: new MemcachedSessionHandler($memcached, ['expiretime' => 3600, 'foo' => 'bar']) — any key outside ['prefix','expiretime','ttl'] triggers the error; common with typos or options copied from RedisSessionHandler (e.g. 'ttl' confusion is fine, but 'host','port','lifetime' are not).
Common situations: Copy-pasting DSN/option arrays between session handler backends; Symfony YAML config referencing an old option name after a library upgrade; typos such as 'expirtime' or 'prefixes'.
Related errors
- Parameter value " " cannot be converted to "bool".
- Parameter " " cannot be converted to enum
- Session has not been set.
- accepts only string as data.
- Unable to create a session ID.
AI-assisted analysis of symfony/http-foundation@5aea19cd67 (2026-09-13).
Data as JSON: /api/errors/2e8a7e55c76df578.
Report an issue: GitHub.
Appendix: source
Thrown at Session/Storage/Handler/MemcachedSessionHandler.php:48
* Key prefix for shared environments.
*/
private string $prefix;
/**
* Constructor.
*
* List of available options:
* * prefix: The prefix to use for the memcached keys in order to avoid collision
* * ttl: The time to live in seconds.
*
* @throws \InvalidArgumentException When unsupported options are passed
*/
public function __construct(
private \Memcached $memcached,
array $options = [],
) {
if ($diff = array_diff(array_keys($options), ['prefix', 'expiretime', 'ttl'])) {
throw new \InvalidArgumentException(\sprintf('The following options are not supported "%s".', implode(', ', $diff)));
}
$this->ttl = $options['expiretime'] ?? $options['ttl'] ?? null;
$this->prefix = $options['prefix'] ?? 'sf2s';
}
public function close(): bool
{
return $this->memcached->quit();
}
protected function doRead(#[\SensitiveParameter] string $sessionId): string
{
return $this->memcached->get($this->prefix.$sessionId) ?: '';
}
public function updateTimestamp(#[\SensitiveParameter] string $sessionId, string $data): bool
{View on GitHub (pinned to 5aea19cd67)