Fatal error: Call to a member function getUserID()
<p>I am getting the following error when I check my site:</p>

<pre><code>Fatal error: Call to a member function getUserID() on a non-object in /home/clientwo/public_html/main/registry/authenticate.php on line 104
</code></pre>

<p>This is the code:</p>

<pre><code>&lt;?php
class Authenticate {

    private $user;
    private $status;
    private $loggedIn = false;

    public function __construct(Registry $registry) {
        $this-&gt;registry = $registry;
        $this-&gt;status = 'User is logged out';
    }

    private function checkForAuthentication() {
        if (isset($_SESSION['sn_auth_session_uid']) &amp;&amp; $_SESSION['sn_auth_session_uid'] &gt; 0) {
            $this-&gt;sessionAuthenticate(intval($_SESSION['sn_auth_session_uid']));
        }
    }

    private function sessionAuthenticate($id) {
        //build a user model
        require_once FRAMEWORK_PATH . 'model/user.php';
        $this-&gt;user = new UserModel($this-&gt;registry, $id);
        //check if user is valid etc
        if ($this-&gt;user-&gt;isValid()) {
            if (!$this-&gt;user-&gt;isActive()) {
                $this-&gt;loggedIn = false;
                $this-&gt;status = 'User has been deleted';
            } else {
                $this-&gt;loggedIn = true;
                $this-&gt;status = 'User is logged in';
            }
        } else {
            $this-&gt;loggedIn = false;
            $this-&gt;status = 'User could not be found';
        }
        //make sure sessions are not set if user is not logged in
        if (!$this-&gt;loggedIn) {
            $this-&gt;logout();
        }
    }

    public function login($username, $password) {
        //first log out
        $this-&gt;logout();
        //execute query
        $this-&gt;registry-&gt;getObject('mysql')-&gt;executeQuery("SELECT UserID FROM user WHERE Username='". $username . "' AND password='" . md5($password) . "'");
        //check if query returned one row
        if ($this-&gt;registry-&gt;getObject('mysql')-&gt;numRows() == 1) {
            //get user row
            $UserData = $this-&gt;registry-&gt;getObject('mysql')-&gt;getRow();
            //build a user model
            require_once FRAMEWORK_PATH . 'model/user.php';
            $this-&gt;user = new UserModel($this-&gt;registry, $UserData['UserID']);
            //check if user is valid and active etc
            if ($this-&gt;user-&gt;isValid()) {
                if ($this-&gt;user-&gt;isActive() == false) {
                    $this-&gt;loggedIn = false;
                    $this-&gt;status = 'User has been deleted';
                } else {
                    $this-&gt;loggedIn = true;
                    $this-&gt;status = 'User is logged in';
                    $this-&gt;user-&gt;increaseLogins();
                    $this-&gt;user-&gt;update();
                    $_SESSION['sn_auth_session_uid'] = $this-&gt;user-&gt;getUserID();
                }
            } else {
                $this-&gt;loggedIn = false;
                $this-&gt;status = 'Authentication failed';
            }
        } else {
            $this-&gt;loggedIn = false;
            $this-&gt;status = 'Authentication failed';
        }
    }

    function logout() {
        //if such a session is set, unset it
        if (isset($_SESSION['sn_auth_session_uid'])) {
            unset($_SESSION['sn_auth_session_uid']);
        }
        //reset to logged out
        $this-&gt;loggedIn = false;
        //reset to null
        $this-&gt;user = null;
    }

    public function isLoggedIn() {
        $this-&gt;checkForAuthentication();
        return $this-&gt;loggedIn;
    }

    public function isAdmin() {
        $this-&gt;checkForAuthentication();
        return $this-&gt;user-&gt;isAdmin();
    }

    public function getUser() {
        $this-&gt;checkForAuthentication();
        return $this-&gt;user;
    }

    public function getUserID() {
        $this-&gt;checkForAuthentication();
        return $this-&gt;user-&gt;getUserID();
    }

    public function getStatus() {
        $this-&gt;checkForAuthentication();
        return $this-&gt;status;
    }



}
?&gt;
</code></pre>
