<?php
include "database/database.php"; // Include your database connection
include "database/data.php"; // Include your database connection

session_start();

if (isset($_SESSION['browser_id'])) {
    $browserId = $_SESSION['browser_id'];
} else {
    // Generate a new browser ID
    $browserId = generateUniqueBrowserId();

    // Store the browser ID in the session for future use
    $_SESSION['browser_id'] = $browserId;
}

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // Fetch and sanitize inputs


    $b_id = $browserId;
    $sql = "SELECT * FROM " . $user_database . " WHERE browser_id='$b_id'";
    $result = $connection->query($sql);
    if ($result && $result->num_rows > 0) {
        while ($row = $result->fetch_assoc()) {

            $user_id = $row['user_name_LL'];
            $user_name = $row['user_name'];


            $sql = "DELETE FROM " . $user_id . " where seller='" . $user_name . "'";
            if ($connection->query($sql) === true) {
      
            } else {
            }
        }
    }

} else {
    echo "<span style='color: red;'>Invalid request method.</span>";
}

function generateUniqueBrowserId()
{
    $randomString = bin2hex(random_bytes(16));
    $timestamp = time();

    return $randomString . $timestamp;
}
?>
