调用成员函数..在字符串上,我如何通过此错误

creating a log in page where if a user is already logged in they are redirected to the home page, however upon execution I get the error code :

call to a member function isloggiedin() on string

what am I doing wrong here?

<?php
include "H:\p3t\phpappfolder\public_php\FYP\includes\api\config\database.php";


if(User::is_loggedin()!="") 
{
    $user->redirect('home.php');
}

if(isset($_POST['btn-login'])) // line  11 where new error exists
{
    $user = $_POST['username'];
    $password = $_POST['password'];

    if(User::login($user,$password))
    {
        $user->redirect('home.php');
    }
    else
    {
        $error = "Wrong Details !";
    }
}
?>

the following code may also help as it is my class.user.php file:

<?php
class USER
{
    private $db;

    function __construct($DB_con)
    {
        $this->db = $DB_con;
    }



    public function login($user,$password)
    {
        try
        {
            $stmt = $this->db->prepare("SELECT * FROM user WHERE user_name=:username OR user_email=:password LIMIT 1");
            $stmt->execute(array(':username'=>$user, $password));
            $userRow=$stmt->fetch(PDO::FETCH_ASSOC);
            if($stmt->rowCount() > 0)
            {
                if(password_verify($password, $userRow['user_pass']))
                {
                    $_SESSION['user_session'] = $userRow['user_id'];
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }
        catch(PDOException $e)
        {
            echo $e->getMessage();
        }
    }

    public function is_loggedin()
    {
        if(isset($_SESSION['user_session']))
        {
            return true;
        }
    }

    public function redirect($url)
    {
        header("Location: $url");
    }

    public function logout()
    {
        session_destroy();
        unset($_SESSION['user_session']);
        return true;
    }
}
?>

as you can see I have the function "isloggedin" so I don't understand why I am getting the error

after following the advice in the answer I was presented with the error message :

Parse error: syntax error, unexpected 'if' (T_IF) in H:\p3t\phpappfolder\public_php\FYP\includes\api\login.php on line 11

$user is the string parameter, not a User object, so you can't use $user->is_loggedin().

The is_loggedin() method doesn't use any class properties, so it can be a static method.

public static function is_loggedin()
{
    return isset($_SESSION['user_session']);
}

Then you can use

if (User::is_loggedin())

Also, you shouldn't set $user and $password before

if (isset($_POST['btn-login']))