<?php
session_start();

// Display everything for debugging
echo '<h2>Session Values:</h2>';
echo '<pre>';
var_dump($_SESSION);
echo '</pre>';

echo '<h2>POST Data Test:</h2>';

// Test setting language directly
if (isset($_GET['test_lang'])) {
    $_SESSION['selected_language'] = $_GET['test_lang'];
    session_write_close();
    echo '<p style="color: green;">✓ Set language to: ' . htmlspecialchars($_GET['test_lang']) . '</p>';
    echo '<p>Redirecting in 2 seconds...</p>';
    echo '<script>setTimeout(() => window.location.href = "?show_session", 2000);</script>';
} elseif (isset($_GET['test_curr'])) {
    $_SESSION['selected_currency'] = $_GET['test_curr'];
    session_write_close();
    echo '<p style="color: green;">✓ Set currency to: ' . htmlspecialchars($_GET['test_curr']) . '</p>';
    echo '<p>Redirecting in 2 seconds...</p>';
    echo '<script>setTimeout(() => window.location.href = "?show_session", 2000);</script>';
} elseif (isset($_GET['show_session'])) {
    echo '<p style="color: blue;">After redirect - Session now contains:</p>';
    echo '<pre>';
    var_dump($_SESSION);
    echo '</pre>';
} else {
    echo '<p><a href="?test_lang=it">Set Language to IT</a></p>';
    echo '<p><a href="?test_curr=eur">Set Currency to EUR</a></p>';
}
?>
