I have to perform on a site, a functionality that allows that when you enter after the url, a / + currency, change the selected currency.
The coins are set in a PHP session variable, so I thought about doing a htaccess redirect to a URL with a file that makes the change of currency and then redirect to the url where it was initially called without the / usd .
The code I use to perform the currency conversion is as follows:
<?php
session_start();
if(isset($_GET['moneda'])){
$moneda = $_GET['moneda'];
$_SESSION['moneda'] = strtoupper($moneda);
}
?>
The problem is that I do not know how to redirect to the same place I was before. I do the redirection in .htaccess with the following line
Redirect 301 /usd /cambio_moneda.php?moneda="usd"
I do not know if this is the right way to make this type of session variables settings by the url.