I've been trying to resolve this for hours now and have looked through many articles here but I still can't find an answer that works.
I want users to be able to set their default currency and not have to set it on every page, so I have this session code on all my pages:
<?php
session_start();
if (isset($_GET['currency'])) {
$_SESSION['currency'] = $_GET['currency'];
}
?>
My currency selector is this:
<a href="index.php?currency=EUR">EUR</a>
<a href="index.php?currency=USD">USD</a>
<a href="index.php?currency=GBP">GBP</a>
When I display the currency, I use this:
<?php print isset($_SESSION['currency']) ? "{$_SESSION['currency']}" : 'usd'; ?>
The idea is to use USD as the default currency but this set up simply doesn't work without the ?currency= variables and when I do set the variable, it's not being saved.
What am I missing?
Thanks