{"record":{"id":"692903a08a00efd4","repo":"ratchetphp/Ratchet","slug":"can-not-change-session-name-in-virtualproxy-692903","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/VirtualProxyForSymfony6.php","lineNumber":58,"sourceCode":"     * {@inheritdoc}\n     */\n    public function setId($id) {\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($name) {\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/VirtualProxyForSymfony6.php#L40-L61","documentation":"VirtualProxyForSymfony6 is the Symfony 6 compatible variant of the VirtualProxy and, like it, forbids changing the session name after the proxy is created; setName() unconditionally throws RuntimeException. The name is fixed by the underlying session storage for the lifetime of the proxy.","triggerScenarios":"Calling setName($name) on the Symfony 6 virtual session proxy, directly or indirectly through code that assumes a fully mutable SessionInterface.","commonSituations":"Symfony 6 applications calling $session->setName() at runtime; bundles or middleware that mutate the session name per-request while the Ratchet session is wrapped in this proxy.","solutions":["Do not call setName on the proxy; configure the session name before the Ratchet server starts (session_name() or session config).","Remove or guard any library/framework code path that mutates the session name while the proxy is active.","If a different session name is genuinely required, create the SessionProvider/session storage with the desired name from the start."],"exampleFix":"// before\n$session->setName('APP_SESSION'); // proxy -> RuntimeException\n// after\n// during bootstrap, before server start:\nini_set('session.name', 'APP_SESSION');","handlingStrategy":"type-guard","validationCode":"if ($session instanceof \\Ratchet\\Session\\Storage\\Proxy\\VirtualProxyForSymfony6) {\n    throw new \\LogicException('Configure the session name in Symfony config; the proxy is immutable.');\n}","typeGuard":"function canRenameSession($session): bool {\n    return !$session instanceof \\Ratchet\\Session\\Storage\\Proxy\\VirtualProxyForSymfony6;\n}","tryCatchPattern":"try {\n    $session->setName($name);\n} catch (\\RuntimeException $e) {\n    // set the name via framework config or session_name() at bootstrap instead\n}","preventionTips":["Configure session name in Symfony framework.yaml (session.name) rather than runtime calls.","Guard third-party code that mutates the session name per-request.","Set session.name via ini before starting the Ratchet server."],"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"}