title: set session variable with fetch array PDO, not working
body: <p>Coding, as I've been learning, is about little details, and I'm missing something because I have the following code:</p>
  
  <pre><code>public function login() {
      if ($_POST) {
        $logdb = new PDO('mysql:host=localhost;dbname=kiko', 'kiko', 'pass');
        $logdb-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $stmt = $logdb-&gt;prepare("SELECT * FROM usreg WHERE email=:email AND password=:pass");
        $stmt-&gt;bindParam(":email", $_POST['email']);
        $stmt-&gt;bindParam(":pass", $_POST['password']);
        $stmt-&gt;execute();
        $loged = $stmt-&gt;fetch();
        $atributes = $stmt-&gt;fetch(PDO::FETCH_ASSOC);
        if ($loged) {
           session_start();
           $_SESSION["loggedIn"] = true;
           $_SESSION["id"] = $atributes-&gt;id;
           $_SESSION["email"] = $_POST['email'];
           $_SESSION["group"] = $atributes-&gt;group;
           $_SESSION["firstname"] = $atributes-&gt;firstname;
           $_SESSION["lastname"] = $atributes-&gt;lastname;
           $_SESSION["phone"] = $atributes-&gt;phone;
           $_SESSION["mobile"] = $atributes-&gt;mobile;
           $_SESSION["adress"] = $atributes-&gt;adress;
           $_SESSION["city"] = $atributes-&gt;city;
           $_SESSION["country"] = $atributes-&gt;country;
        } else {
            echo 'wrong login try again';
          }
        } else {
            echo '&lt;form name="login" action="" method="POST"&gt;
        Email: &lt;br /&gt;
        &lt;input type="text" name="email"/&gt;&lt;br /&gt;
        Password: &lt;br /&gt;
        &lt;input type="password" name="password"/&gt;&lt;br /&gt;
        &lt;button type="submit"&gt;Login&lt;/button&gt;
        &lt;a href="register.php"&gt;Register&lt;/a&gt;&lt;/form&gt;';
        }
    }
  </code></pre>
  
  <p>and everything works well except the part where I'm registering globals. What I'm trying to do is set the global session the details from the fetch array atributes, I tried with:</p>
  
  <pre><code> $atributes = $stmt-&gt;fetch(PDO::FETCH_OBJ);
  </code></pre>
  
  <p>but the result is the same, and I changed the email from array to <code>POST</code> and it works because when I do:</p>
  
  <pre><code>echo $_SESSION['email'];
  </code></pre>
  
  <p>It works, but the fetch is not passing the details to the other session globals. What should I put in there to sucess what I'm trying to do can you guys help me? Do I need another kind of prepared statement? Is it missing results because I'm making the <code>WHERE</code> clause?</p>