<?php
session_start();
require 'conexion.php';

$sesion_id = $_SESSION['sesion_id'] ?? 0;

if ($sesion_id > 0) {
  $hora = date('Y-m-d H:i:s');
  mysqli_query($con, "UPDATE sesiones_usuarios SET hora_salida = '$hora' WHERE id = $sesion_id");
}

session_destroy();
header("Location: index.php");
exit;
