public function __construct() { self::$mysqli = new mysqli(ATC_SETTING_DB_HOST, ATC_SETTING_DB_USER, ATC_SETTING_DB_PSWD, ATC_SETTING_DB_NAME); /* check connection */ if (mysqli_connect_errno()) { throw new ATCExceptionDBConn(mysqli_connect_error()); } if (isset($_COOKIE['sessid'])) { try { $details = self::check_user_session($_COOKIE['sessid']); self::$currentuser = $details->personnel_id; self::$currentpermissions = $details->access_rights; } catch (ATCExceptionInvalidUserSession $e) { if (substr($_SERVER['SCRIPT_NAME'], -9, 9) != "login.php") { header('Location: login.php', true, 302); } } } }