<?php
// config.php ko shaamil karein, jo session shuru karega
require_once 'config.php';

// Suraksha jaanch: Sirf wahi user switch back kar sakta hai jo pehle se admin ke roop mein logged in tha
if (!isset($_SESSION['admin_id'])) {
    // Agar koi admin session nahi hai, to use dashboard par bhej dein
    header("Location: dashboard.php");
    exit();
}

// Admin ki original session details ko wapas laayein
$_SESSION['user_id'] = $_SESSION['admin_id'];
$_SESSION['user_name'] = $_SESSION['admin_name'];
$_SESSION['user_roles'] = $_SESSION['admin_roles'];

// Temporary admin session variables ko हटा dein
unset($_SESSION['admin_id']);
unset($_SESSION['admin_name']);
unset($_SESSION['admin_roles']);

// Admin ko uske dashboard par wapas bhej dein
header("Location: dashboard.php");
exit();
?>