<?php
session_start();
if (!isset($_SESSION['id_users'])) {
    header("Location: ../login.php");
    exit;
}

// Verificar tiempo de inactividad (30 minutos)
if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 1800)) {
    session_unset();
    session_destroy();
    header("Location: ../login.php?session=expired");
    exit;
}
$_SESSION['LAST_ACTIVITY'] = time();
?>