<?php
/**
 * MachForm
 * 
 * © 2007–2025 Appnitro Software. All rights reserved.
 * 
 * This source code is proprietary and may not be copied, modified,
 * or distributed in any form without express written permission from Appnitro Software.
 * 
 * License information: https://www.machform.com/license-agreement/
 */
	require('config.php');
	require('lib/db-session-handler.php');
	require('includes/init.php');
	require('includes/db-core.php');
	require('includes/helper-functions.php');

	$dbh = mf_connect_db();
	
	$current_dir = dirname($_SERVER['PHP_SELF']);
    if($current_dir == "/" || $current_dir == "\\"){
		$current_dir = '';
	}
	
	$user_id  = $_SESSION['mf_user_id'];
	$_SESSION = array();

	//delete the remember me cookie — flags must match the set-cookie call in index.php so the browser overwrites it
	setcookie('mf_remember', '', [
		'expires'  => time() - 3600,
		'path'     => '/',
		'secure'   => $is_https_enabled,
		'httponly' => true,
		'samesite' => 'Lax',
	]);
	$query = "update ".MF_TABLE_PREFIX."users set cookie_hash=? where user_id=?";
	$params = array('',$user_id);
	mf_do_query($query,$params,$dbh);

	header("Location: ".$current_dir."/index.php");
	exit;
?>