<?php require_once __DIR__ . '../../../../businessLogic/business.php'; $business = new business(); if (isset($_COOKIE['auth'])) { $token = $_COOKIE['auth']; $id; $info = $business->check_token($token); if ($info != FALSE) { $user = $business->view_user($info['id']); $username = $user['loginId']; $usertype = $business->get_user_type($username); if ($usertype == 'admin') { header('Location: ./../root.admin.companies.list/list.php'); exit; } else { echo '<script>console.log("not authorized");</script>'; header('Location: ./../root.login/login.php'); exit; } } else { echo '<script>console.log("wrong token");</script>'; header('Location: ./../root.login/login.php'); exit; } } else { echo '<script>console.log("no token found");</script>'; header('Location: ./../root.login/login.php'); exit; }