How to set sessions in pdo? //PHP -


in mysqli easy:::

$_session['userphoto'] = $row['userphoto'];

how set in pdo?

update..:complete loginconnection.php

    if ($_server['request_method'] == 'post'){     require 'pdo.php';      $stmt = $pdo->prepare("select email, senha login email=:email , senha=:senha");     $stmt->bindparam(':email', $_post['email']);     $stmt->bindparam(':senha', md5($_post['senha']));     $stmt->execute();     $row = $stmt->fetchall(pdo::fetch_assoc);      if($row > 0){     $_session['email'] = $_post['email'];     $_session['userphoto'] = $row['userphoto'];     $_session['nome'] = $row->nome;     $_session['id'] = $row['id'];     unset ($_session['wronginfos']);     header("location: /");      } else {      $_session['wronginfos'] = 'usuário/senha incorreto(a) !';      //limpa     unset ($_session['email']);     unset ($_session['nome']);     unset ($_session['userphoto']);     unset ($_session['id']);      //redireciona para página de autenticação     header('location:/');      }     } else {     } 

[[it looks post code; please add more details.]](text only, text only, text only, text only, text only, text only, text only, text only, text only, text only, text only, text only, text only)

your sessions aren't set because haven't specified want start them.. need add top of every script plan use sessions in.

session_start(); 

further more, @user4789619 stated in answer, can't re-declare $row variable that.


another note, if want check rows returned did

if($row > 0) {... 

you need check rowcount doing this:

if($stmt->rowcount() > 0) { ... 

read more rowcount()

further more, you're mixing whole range of stuff won't work. you're fetching data pdo::fetch_assoc associative array, yet you're trying call $row->nome; object.... on top of that, aren't selecting rows... select email, senha login


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

node.js - How to abort query on demand using Neo4j drivers -