<?php
session_start();
date_default_timezone_set('Africa/Blantyre');
include_once 'model/users_model.php';
$users_model = new users_model();

$username = $_GET['username'];
$session_id = $_GET['session_id'];

$logout_time = date('Y-m-d H:i:s');

$redirect_page = "../index.php";

$cancel_active = $users_model->cancelActive($username);

if($cancel_active == true){
    $logout = $users_model->logoutUpdates($logout_time, $session_id);
    session_destroy();
    session_start();
        $_SESSION['notification']= [
            'type' => 'success',
            'title' => 'SUCCESS',
            'message' => 'Successfully Logged Out of Active Sessions<br>'
        ];
    header("Location: $redirect_page");
    exit();
}
?>
