We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Store and present session variable

I am storing the following session variables

public function ingresoAction() {

        $usuario = $this->request->getPost('usuario', array('striptags', 'trim'));
        $password = $this->request->getPost('password', array('striptags', 'trim'));
        $request = $this->request;
        if ($request->isPost()) {
            $usua = SeperPerson::findFirst("SEPER_USUARI='$usuario' AND SEPER_CLAVEX='$password'");
            if (!$usua) {
                echo "no encontrado";
            } else {
                    $this->session->set("userId", $usua->SEPER_USUARI);
                    $this->session->set("email", $usua->SEPER_EMAILX);
                    $this->session->set("codigo", $usua->SEPER_CODIGO);
                    $this->session->set("username",  $usua->SEPER_USUARI);
                    $this->session->set("registered", true);
                    $this->session->set("loggedIn", true);
                    $this->session->set("tipox",  $usua->SEPER_TIPOXX);
                    $this->flash->success('Welcome ' .  $usua->SEPER_NOMBRE);
                    if ($usua->SEPER_TIPOXX == 'U') {
                        return $this->response->redirect('carrito/carrito');
                    } ELSE {
                        return $this->response->redirect('index');
                    }

            }
        }
    }

pero al presentarlas de la siguiente manera solo me presenta el texto "1"

echo $this->session->has("userId")

But in presenting them as follows, I only present the text "1"

The data is retrieved but not saved in the session variable or stored badly. What could it be?
edited Jan '17

Because has method is to check if session has such an key. So it just returns true/false always. Also i would recommend to change your code because it's super bad:

$this->session->set('userData', $usua->toArray(['column1', 'column2']);

And just get userData and display it in view. Much simpler.