0, 'path' => '/', 'domain' => $host, 'secure' => true, 'httponly' => true, 'samesite' => 'Strict' ]); } } session_start(); if (isset($_SESSION['user_id'])) { header('Location: index.php'); exit; } $error = ''; $theme = $_COOKIE['theme'] ?? 'light'; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $username = $_POST['username'] ?? ''; $password = $_POST['password'] ?? ''; $user = loginUser($username, $password); if ($user) { header('Location: index.php'); exit; } else { $error = 'Usuario o contraseña incorrectos'; } } ?>