ssh - how to run multiple ssh2 command in same session in php

one text

I'm having some problems with PHP SSH2 commands. I need to exec this bash command in same session but it does not work. If i run this file this file give just one json response.

$ssh = new Net_SSH2($server);
if (!$ssh->login($user, $pass)) {
echo "error";
}
for ($i = 1; $i <= 50; $i++){
$cfg = generateRandomString();
   echo $ssh->exec("bash setup_v2.sh 1 usercf passtest ".$cfg.""); 

}

However if i run this file and restart connection it gives 11 different json response. Problem is how can i take 50 or more different response?

for ($i = 1; $i <= 50; $i++){

$ssh = new Net_SSH2($server);
if (!$ssh->login($user, $pass)) {
echo "error";
}
$cfg = generateRandomString();
   echo $ssh->exec("bash setup_v2.sh 1 usercf passtest ".$cfg.""); 


 }

Source