<?php
session_start();

/* 🔒 NO SESSION → HOME */
if (!isset($_SESSION['teacher_id']) && !isset($_SESSION['institution_id'])) {
    header("Location: /rs_lab/index.php");
    exit;
}

/* 🧑‍🏫 TEACHER — FIRST PRIORITY */
if (isset($_SESSION['teacher_id']) && ($_SESSION['user_role'] ?? '') === 'teacher') {
    header("Location: /rs_lab/teacher/teacher_dashboard.php");
    exit;
}

/* 🏫 INSTITUTION */
if (isset($_SESSION['institution_id'])) {
    header("Location: /rs_lab/institution/dashboard.php");
    exit;
}

/* fallback */
header("Location: /rs_lab/index.php");
exit;