Files
pilates-platform/includes/logout.php
Francesco Picone 4e41ca9bf7 fix
2025-12-03 18:35:21 +01:00

34 lines
720 B
PHP

<?php
/**
* Logout
*
* Termina la sessione utente e reindirizza alla home
*/
require_once '../config.php';
require_once 'functions.php';
session_start();
// Log attività prima di fare logout
if (is_logged_in()) {
$pdo = get_db_connection();
$stmt = $pdo->prepare("
INSERT INTO activity_log (user_id, action, description, ip_address, user_agent, created_at)
VALUES (?, 'logout', 'Utente ha effettuato il logout', ?, ?, NOW())
");
$stmt->execute([
$_SESSION['user_id'],
$_SERVER['REMOTE_ADDR'] ?? null,
$_SERVER['HTTP_USER_AGENT'] ?? null
]);
}
// Effettua il logout
logout_user();
// Reindirizza alla home
header('Location: ../index.php');
exit;
?>