<?php
    include_once('../components/connect.php');

    header("Access-Control-Allow-Origin: *");
    header("Access-Control-Allow-Headers: access");
    header("Access-Control-Allow-Methods: POST");
    header("Content-Type: application/json; charset=UTF-8");
    header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
    include_once('helper_functions.php');

    try {
        unset($_SESSION['user_id']);
        session_destroy();
        $resp['msg'] = '';
        $resp['success'] = true;
    } catch (Exception $e) {
        $resp['msg'] = 'Error: ' . $e->getMessage();
        $resp['success'] = false;
    }
    echo json_encode($resp);
?>