symfony/http-foundation · error · InvalidArgumentException
The following options are not supported
Error message
The following options are not supported "%s".
What it means
RedisSessionHandler's constructor accepts only two options keys: 'prefix' (session key prefix, default 'sf_s') and 'ttl' (max lifetime override). Any other key in $options raises this InvalidArgumentException listing the unsupported keys. Unlike the PDO handler, the Redis handler does not take per-handler table/column or locking options.
Solutions
- Keep only 'prefix' and 'ttl' keys in the options array; move other settings to the right place (session.gc_maxlifetime in php.ini/framework session config, storage schema options to the PDO handler).
- Fix key casing/typos: exactly 'prefix' and 'ttl'.
- If you need connection-level settings, configure them on the \Redis/\Predis client itself (timeout, database, auth), not the handler options.
- Diff your options array against ['prefix','ttl'] (array_diff(array_keys($options), ['prefix','ttl'])) in a config test to catch this in CI.
Example fix
// before new RedisSessionHandler($redis, ['prefix' => 'sess:', 'db_table' => 'sessions']); // after new RedisSessionHandler($redis, ['prefix' => 'sess:']);
Defensive patterns
Strategy: validation
Validate before calling
$allowed = ['prefix', 'ttl'];
if ($diff = array_diff(array_keys($options), $allowed)) {
throw new LogicException('RedisSessionHandler does not support options: ' . implode(', ', $diff));
} Try / catch
try {
$handler = new RedisSessionHandler($redis, $options);
} catch (\InvalidArgumentException $e) {
if (str_contains($e->getMessage(), 'options are not supported')) {
$handler = new RedisSessionHandler($redis, array_intersect_key($options, ['prefix' => 1, 'ttl' => 1]));
} else {
throw $e;
}
} Prevention
- Keep a whitelist of ['prefix','ttl'] when building handler options
- Do not reuse PdoSessionHandler option arrays with RedisSessionHandler
- Watch for case-sensitive key typos ('prefix', 'ttl')
- Configure connection settings on the Redis client object, not handler options
When it happens
Trigger: new RedisSessionHandler($redis, [...]) with any option other than 'prefix'/'ttl' — commonly copying PdoSessionHandler options like 'db_table', 'lock_mode', 'gc_maxlifetime', 'col_lifetime', or framework session config keys (cookie_lifetime, gc_maxlifetime) into the handler options array.
Common situations: Migrating from PdoSessionHandler to RedisSessionHandler and reusing the same options array; typos like 'preifx' or 'TTL' (options keys are case-sensitive); framework YAML config where handler options and session config are conflated.
Related errors
- Invalid argument $savePath
- You must provide the "database" and "collection" option for…
- The disposition must be either
- The filename fallback cannot contain the "%" character.
- The session handler " " does not support clearing all…
AI-assisted analysis of symfony/http-foundation@5aea19cd67 (2026-09-13).
Data as JSON: /api/errors/92c140bf6f7a8692.
Report an issue: GitHub.
Appendix: source
Thrown at Session/Storage/Handler/RedisSessionHandler.php:47
/**
* Time to live in seconds.
*/
private int|\Closure|null $ttl;
/**
* List of available options:
* * prefix: The prefix to use for the keys in order to avoid collision on the Redis server
* * ttl: The time to live in seconds.
*
* @throws \InvalidArgumentException When unsupported client or options are passed
*/
public function __construct(
private \Redis|Relay|\RedisArray|\RedisCluster|\Predis\ClientInterface $redis,
array $options = [],
) {
if ($diff = array_diff(array_keys($options), ['prefix', 'ttl'])) {
throw new \InvalidArgumentException(\sprintf('The following options are not supported "%s".', implode(', ', $diff)));
}
$this->prefix = $options['prefix'] ?? 'sf_s';
$this->ttl = $options['ttl'] ?? null;
}
protected function doRead(#[\SensitiveParameter] string $sessionId): string
{
return $this->redis->get($this->prefix.$sessionId) ?: '';
}
protected function doWrite(#[\SensitiveParameter] string $sessionId, string $data): bool
{
$ttl = ($this->ttl instanceof \Closure ? ($this->ttl)() : $this->ttl) ?? \ini_get('session.gc_maxlifetime');
$result = $this->redis->setEx($this->prefix.$sessionId, (int) $ttl, $data);
return $result && !$result instanceof ErrorInterface;
}View on GitHub (pinned to 5aea19cd67)