Below is a very basic example of the trouble I am having.
Now why must I use $session = new Session(); in the database.class.php file when in my system the files are included in a way that it would be visible already.
In other words I cannot call $session = new Session(); outside of any other classes, to make it work in other classes I have to call create a new objectof the session class in every class I want to use it in, how can I avoid this and make it work without doing that?
// Session.class.php
class Session{
public function __construct()
{
session_start();
}
public function set($name, $value)
{
$_SESSION[$name] = $value;
}
}
...
// Database.class.php
class Database{
public static function mysql_query_2($query)
{
if ($session->get('user_role') == 10){
$_SESSION['queries']++;
}
return mysql_query($query);
}
}