I am recieving fatal error when I am trying to call a class Session. I have no idea, where could be a problem (Googled for about an hour), so if someone will find it, please, I will be very thankful.
Error

```
Fatal error: Call to a member function generateRandID() on a non-object in C:\xampp\htdocs\engine\session.php on line 35

```

Class

```
    <?php
if (file_exists('install'))
    header("Location: install/");

include_once("game/engine/database/connection.php");
include_once("engine/config.php");
include_once("engine/database/db_MYSQL.php");

include_once ("engine/generator.php");

class Session {
    private $time;
    var $referrer, $url;
    var $logged_in = false;
    public $userinfo = array();

    function Session() {
        global $database;
        $this->time = time();
        session_start();

        $this->logged_in = $this->checkLogin();

        if(isset($_SESSION['url']))
            $this->referrer = $_SESSION['url'];
        else
            $this->referrer = "/";
        $this->url = $_SESSION['url'] = $_SERVER['PHP_SELF'];
        $this->SurfControl();
    }

    public function Login($user) {
        global $database, $generator;
        $this->logged_in = true;
        $_SESSION['sessionId'] = $generator->generateRandID();
        $_SESSION['username'] = $user;

        $database->updateUserField($_SESSION['username'], "sessionId", $_SESSION['sessionId'], 0);
        header("Location: index.php");
    }

    public function Logout() {
        global $database;
        $this->logged_in = false;
        $database->updateUserField($_SESSION['username'], "sessid", "", 0);
        if(ini_get("session.use_cookies"))
            $params = session_get_cookie_params();
        session_destroy();
        session_start();
    }

    private function checkLogin() {
        global $database;
        if (isset($_SESSION['username']) && isset($_SESSION['sessionId'])) {
            if (!$database->checkActiveSession($_SESSION['username'], $_SESSION['sessionId'])) {
                $this->Logout();
                return false;
            }
            else {
                //update database
                $database->updateUserField($_SESSION['username'], "isOnline", 1, 0);
                return true;
            }
        }
        else
            return false;
    }

    private function SurfControl() {
        if (SERVER_WEB_ROOT)
            $page = $_SERVER['SCRIPT_NAME'];
        else {
            $explode = explode("/", $_SERVER['SCRIPT_NAME']);
            $i = count($explode) - 1;
            $page = $explode[$i];
        }
        $pagearray = array("overview.php", "logout.php", "inventoryswap.php", "shop.php", "map.php", "messages.php", "training.php", "work.php", "ajax.php", "packageswap.php", "report.php", "location.php");
        $pagearray1 = array("index.php");
        if(in_array($page, $pagearray1) && $this->logged_in)
            header("Location: game/overview.php");
        else if (in_array($page, $pagearray) && !$this->logged_in)
            header("Location: index.php");
    }
};

$session = new Session;

```

?>