well, you can easily provide the PHPSESSIONID to the /src/Controller/MyWebSocket.php or /src/MyWebSocket.php script ( Websocket SERVER SIDE) if you do this in your view :
<?php
$session_id = $_COOKIE['PHPSESSID'] ?? null;
?>
<script>
const sessionId = "<?php echo $session_id; ?>";
console.log(sessionId);
console.log("Connection established!");
var conn = new WebSocket('ws://localhost:8080?session_id=' + sessionId);
in the Controller you can use this through ws provided PHPSESSIONID like that:
public function onOpen(ConnectionInterface $conn)
{
$uri = $conn->httpRequest->getUri();
$query_params = [];
parse_str($uri->getQuery(), $query_params);
$session_id = $query_params['session_id'] ?? null;
echo "Session ID: " . $session_id . PHP_EOL;
there you need to do something like:
$session = new Session();
$session->start();
$session->id($session_id);
$user_id = $session->read(‘Auth.User.id’);
this should give you access to the information that is saved in $this->request->getSession()->read(‘Auth’); which is available on your view ( HTTP SERVER SIDE)… but i dont know how to do it… you have to use the bootstrap / middleware in somehow!..
btw do you think it is enough to use WSS instead of WS? WSS will be the same like HTTPS… i saw some plugins to encrypt cookies etc but wss should do it already i guess…
idea?