public function login($email, $password) { //Select users row from database base on $email $selection = 1; $login_connection_select_result = parent::findUserForLogin($email); while ($login_connection_select_result) { // echo $login_connection_select_result['email']; $password = $login_connection_select_result['user_salt'] . $password; /* echo "<br>"; echo "<br>"; echo $r['user_salt'];*/ $password = $this->hashData($password); /* echo "<br>"; echo "<br>"; echo $password;*/ $is_active = (bool) $login_connection_select_result['is_active']; $is_verified = (bool) $login_connection_select_result['is_verified']; /* echo $is_active; echo $is_verified;*/ if ($password == $login_connection_select_result['password']) { if ($is_active == true && $is_verified == true) { /* echo "Sucess";*/ $random = $this->randomString(); $token = $_SERVER['HTTP_USER_AGENT'] . $random; $token = $this->hashData($token); $user_agent = $_SERVER['HTTP_USER_AGENT']; $session_id = 1; $user_id = $login_connection_select_result['id']; $encryption_key = $this->encryption_key; $encrypted_user_id = $this->encode($user_id); $time = time(); setcookie("athToken", $encrypted_user_id, time() + 86400); //Setup sessions vars if (!isset($_SESSION)) { session_start(); } $message = parent::insertLoginSession($login_connection_select_result['id'], $session_id, $token, $user_agent); /* echo "0";*/ return "0"; } else { if ($is_active == true) { echo "You're not an verified user"; /* echo "2";*/ return "2"; } else { if ($is_verified == true) { echo "You're not an activated user"; /* echo "3";*/ return "3"; } else { echo "You're not activated/verified"; /* echo "4";*/ return "4"; } } } } else { echo "You're credentials are incorect"; /* echo "1";*/ return "1"; } } /* } catch (PDOException $pe) { die("Could not connect to the database $dbname :" . $pe->getMessage()); }*/ }