<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
    <title>Session Debug</title>
</head>
<body>
    <h1>Session Debug</h1>
    <pre><?php print_r($_SESSION); ?></pre>
    
    <h2>Set Language to IT</h2>
    <button onclick="testLanguage('it')">Test IT</button>
    
    <h2>Set Currency to EUR</h2>
    <button onclick="testCurrency('eur')">Test EUR</button>
    
    <div id="output"></div>
    
    <script>
    function testLanguage(lang) {
        fetch('/emporio-sport/api_set_preference.php', {
            method: 'POST',
            headers: { 'Content-Type': 'application/json' },
            body: JSON.stringify({ type: 'language', value: lang })
        })
        .then(r => r.json())
        .then(data => {
            console.log('Language response:', data);
            document.getElementById('output').innerHTML = '<pre>' + JSON.stringify(data, null, 2) + '</pre>';
            setTimeout(() => location.reload(), 1000);
        });
    }
    
    function testCurrency(curr) {
        fetch('/emporio-sport/api_set_preference.php', {
            method: 'POST',
            headers: { 'Content-Type': 'application/json' },
            body: JSON.stringify({ type: 'currency', value: curr })
        })
        .then(r => r.json())
        .then(data => {
            console.log('Currency response:', data);
            document.getElementById('output').innerHTML = '<pre>' + JSON.stringify(data, null, 2) + '</pre>';
            setTimeout(() => location.reload(), 1000);
        });
    }
    </script>
</body>
</html>
