The users on the application are logged in by their e-mail. This e-mail is in a session. With this session I try to get more information of that user to print out there (sur)names and the avatar. When I do it in my navbar he's doing it all well but on the page itself it gives the following error: 'Fatal error: Cannot use object of type User as array'
What am i doing wrong?
PHP:
$user = new User();
$email = $_SESSION['email'];
$user->getUserInfoByEmail($email);
var_dump($user['avatar']);
FUNCTION:
public function getUserInfoByEmail($email)
{
$db = new Db();
$select = "SELECT * FROM tblusers WHERE email = '" . $_SESSION["email"] . "';";
$result = $db->conn->query($select);
return $data=$result->fetch_assoc();
}