<?php
declare(strict_types=1);
if (session_status() === PHP_SESSION_NONE) session_start();

// Destroy only teacher-portal session keys (preserves main portal session if active)
unset($_SESSION['tp_user_id'], $_SESSION['tp_user_name'], $_SESSION['tp_user_role']);

// If no main portal session remains, destroy fully
if (empty($_SESSION['user_id'])) {
    session_destroy();
}

header('Location: login.php');
exit;
