<?php
ini_set('session.use_only_cookies', 1);
ini_set('session.cookie_httponly', 1);
ini_set('session.use_strict_mode', 1);

if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') {
    ini_set('session.cookie_secure', 1);
}

session_name('investpro_session');
session_start();
session_regenerate_id(true);

// Timeout da sessão: 63 minutos
if (isset($_SESSION['last_activity']) && (time() - $_SESSION['last_activity']) > 3800) {
    session_unset();
    session_destroy();
    header('Location: ../login.php');
    exit;
}
$_SESSION['last_activity'] = time();

// Verifica se é admin autenticado
if (!isset($_SESSION['admin_session'])) {
    header('Location: ../login.php');
    exit;
}
?>
