title: Call to a member function, getting fatal error
body: <p>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</p>
  
  <pre><code>Fatal error: Call to a member function generateRandID() on a non-object in C:\xampp\htdocs\engine\session.php on line 35
  </code></pre>
  
  <p>Class</p>
  
  <pre><code>    &lt;?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-&gt;time = time();
          session_start();
  
          $this-&gt;logged_in = $this-&gt;checkLogin();
  
          if(isset($_SESSION['url']))
              $this-&gt;referrer = $_SESSION['url'];
          else
              $this-&gt;referrer = "/";
          $this-&gt;url = $_SESSION['url'] = $_SERVER['PHP_SELF'];
          $this-&gt;SurfControl();
      }
  
      public function Login($user) {
          global $database, $generator;
          $this-&gt;logged_in = true;
          $_SESSION['sessionId'] = $generator-&gt;generateRandID();
          $_SESSION['username'] = $user;
  
          $database-&gt;updateUserField($_SESSION['username'], "sessionId", $_SESSION['sessionId'], 0);
          header("Location: index.php");
      }
  
      public function Logout() {
          global $database;
          $this-&gt;logged_in = false;
          $database-&gt;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']) &amp;&amp; isset($_SESSION['sessionId'])) {
              if (!$database-&gt;checkActiveSession($_SESSION['username'], $_SESSION['sessionId'])) {
                  $this-&gt;Logout();
                  return false;
              }
              else {
                  //update database
                  $database-&gt;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) &amp;&amp; $this-&gt;logged_in)
              header("Location: game/overview.php");
          else if (in_array($page, $pagearray) &amp;&amp; !$this-&gt;logged_in)
              header("Location: index.php");
      }
  };
  
  $session = new Session;
  </code></pre>
  
  <p>?></p>