<?php
// logout.php
include('inc/db.php');

session_start();

if (isset($_COOKIE['remember_token'])) {
    $token = $_COOKIE['remember_token'];

    $sql = "DELETE FROM login_tokens WHERE token = ?";
    $stmt = mysqli_prepare($conn, $sql);
    mysqli_stmt_bind_param($stmt, "s", $token);
    mysqli_stmt_execute($stmt);

    setcookie('remember_token', '', time() - 3600, "/");
}

session_destroy();
header('Location: login.php');
exit();
