0 ){ // get/send name to web socket $wsi->send(['operation' => "Connect",'type' => 'user', 'name' => $_SESSION['USER']['username']]); $check = $wsi->receive(); if( $check['error'] == false ) $_SESSION['NAME'] = $check['name']; }elseif( count($_SESSION['ADMIN']) > 0 ){ // get/send name to web socket $wsi->send(['operation' => "Connect",'type' => 'admin', 'name' => $_SESSION['ADMIN']['username']]); $check = $wsi->receive(); if( $check['error'] == false ) $_SESSION['NAME'] = $check['name']; }else{ // get/send name to web socket $wsi->send(['operation' => "Connect",'type' => 'guest', 'name' => null]); $check = $wsi->receive(); if( $check['error'] == false ) $_SESSION['NAME'] = $check['name']; } $wsi->close(); $wsi = null; $_SESSION['WS'] = false; } } }