<?php
// Must match the session name used everywhere else in the app
session_name('mhp_purchasing_session');
session_start();

// Wipe all session data
$_SESSION = [];

// Delete the session cookie from the browser
if (ini_get('session.use_cookies')) {
    $params = session_get_cookie_params();
    setcookie(
        session_name(), '', time() - 42000,
        $params['path'], $params['domain'],
        $params['secure'], $params['httponly']
    );
}

// Destroy the server-side session
session_destroy();

header('Location: login.php');
exit;
