Store query result in a session with PDO

1

I have a SELECT which generates results normally, but when I need to get the value of some column to use on another page it does not work.

Query code and attempt to pass the result of a column to a session:

$login = $conexao->prepare("SELECT pessoa.id_login, pessoa.nome 'pnome',
pessoa.id_funcao, pessoa.id_pessoa 'idP', funcao.funcao
FROM login as login
JOIN pessoa as pessoa
on login.id_login = pessoa.id_login 
OIN funcao as funcao 
on pessoa.id_funcao = funcao.id_funcao 
WHERE login.login= :user AND login.senha=:passwd LIMIT 1"); 

$login->bindParam(":user",$user, PDO::PARAM_STR);
$login->bindParam(":passwd",$passwd, PDO::PARAM_STR);
$login->execute();


if($login->rowCount()==1){
   $login->fetch(PDO::FETCH_OBJ);
   $this->setLogado($logado=true);

   echo $_SESSION['user'] = $user;
   echo "<br>".$_SESSION['passwd'] = $passwd;
   echo "<br>".$_SESSION['id_pessoa'] = $login->id_pessoa;
   echo "<br>".$_SESSION['abc'] = $login->pnome;

Error that PHP returns:

Note that the SESSIONS that had the value assigned by the variables $user and $passwd function normally.

    
asked by anonymous 30.10.2018 / 00:44

0 answers