{"record":{"id":"569216ced61b2f64","repo":"ratchetphp/Ratchet","slug":"can-not-change-session-name-in-virtualproxy-569216","errorCode":null,"errorMessage":"Can not change session name in VirtualProxy","messagePattern":"Can not change session name in VirtualProxy","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/Ratchet/Session/Storage/Proxy/VirtualProxyForSymfony7.php","lineNumber":58,"sourceCode":"     * {@inheritdoc}\n     */\n    public function setId(string $id): void {\n        $this->_sessionId = $id;\n    }\n\n    /**\n     * {@inheritdoc}\n     */\n    public function getName(): string {\n        return $this->_sessionName;\n    }\n\n    /**\n     * DO NOT CALL THIS METHOD\n     * @internal\n     */\n    public function setName(string $name): void {\n        throw new \\RuntimeException(\"Can not change session name in VirtualProxy\");\n    }\n}\n","sourceCodeStart":40,"sourceCodeEnd":61,"githubUrl":"https://github.com/ratchetphp/Ratchet/blob/e621c6c40bf684bbbb877102416ad5303d05a9cc/src/Ratchet/Session/Storage/Proxy/VirtualProxyForSymfony7.php#L40-L61","documentation":"VirtualProxyForSymfony7 is the Symfony 7 variant of the proxy with the string-typed setName(string $name): void signature; it unconditionally throws RuntimeException because the session name of a virtual proxy is immutable by design.","triggerScenarios":"Calling setName('...') on the Symfony 7 virtual session proxy, directly or via framework/session abstraction layers that mutate the session name at runtime.","commonSituations":"Symfony 7 apps or bundles calling $session->setName() on the injected session; migration from Symfony 6/5 code that renamed sessions mid-request and now hits the proxy guard.","solutions":["Set the desired session name during bootstrap (session_name()/ini) before the Ratchet server and proxy are created.","Remove runtime setName() calls on the proxied session; treat the session name as immutable for the connection.","Configure the name through framework/session configuration rather than mutating the proxy."],"exampleFix":"// before\n$session->setName('SESSID7'); // proxy -> RuntimeException\n// after\n// bootstrap, before server start:\nsession_name('SESSID7');","handlingStrategy":"type-guard","validationCode":"if ($session instanceof \\Ratchet\\Session\\Storage\\Proxy\\VirtualProxyForSymfony7) {\n    throw new \\LogicException('Session name is immutable on the Symfony 7 virtual proxy.');\n}","typeGuard":"function canRenameSession($session): bool {\n    return !$session instanceof \\Ratchet\\Session\\Storage\\Proxy\\VirtualProxyForSymfony7;\n}","tryCatchPattern":"try {\n    $session->setName($name);\n} catch (\\RuntimeException $e) {\n    // configure session.name at bootstrap/framework config instead\n}","preventionTips":["When migrating to Symfony 7, remove runtime setName() calls on Ratchet session proxies.","Declare session name in framework configuration (framework.session.name).","Call session_name() before server startup, never inside connection handlers."],"tags":["php","session","symfony","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"e621c6c40bf684bbbb877102416ad5303d05a9cc","analyzedAt":"2026-09-16T00:13:27.878Z","contentChangedAt":"2026-09-16T00:13:27.878Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}