А востановить пременную из сессии забыл?
session_start();
if ($userData['password'] == $password) {
$connect = true;
$_SESSION['connect'] =$connect;
} else {
$connect = $_SESSION['connect'];
}
if ($connect == true) {
echo "yes";
}
else {
echo "no";
}