<?php

session_start();
require('app/app.php');

if (!isset($_SESSION['username'])) {
    redirect('login.php');
}
Data::get_record_login_date();
Data::delete_record($_SESSION['username']);

// // query login date to save on history
// $query = "Select login_date from tbl_online where username = '" .$_SESSION['username'] . "'";
// $result = mysqli_query($connection, $query);
// $row = mysqli_fetch_assoc($result);
// $login_date = $row['login_date'];

// // save record in history once logout
// $query = "INSERT INTO tbl_login_history(sysdttm, username, login_date) VALUES('". $login_date ."', '". $_SESSION['username']."', '". $login_date ."')";
// $result = mysqli_query($connection, $query);

// delete record once logout
// $query = "DELETE FROM tbl_online WHERE username = '" . $_SESSION['username'] . "'";
// $result = mysqli_query($connection, $query);
session_unset();
session_destroy();





redirect('login.php');
die();
