Set cookie inside websocket connection
<p>I know that I can set cookies during handshake:</p>

<pre><code>const wss = new WebSocketServer({ server, path: '/ws' });
wss.on('headers', headers =&gt; {
  headers.push('Set-Cookie: my-cookie=qwerty');
});
</code></pre>

<p>How can I change cookies inside websocket connection?
For example, I want to set session cookie after some client message:</p>

<pre><code>ws.on('message', () =&gt; {
  // something like ws.setCookie('my-cookie=qwerty');
});
</code></pre>