Print the values of $_POST and $_COOKIE?

Good day!
Got confused with the task of printing currency on the website at all, tried different ways using jquery, including...
The website on Bitrix. There is a selector in the header, in the template. Send POST to a conclusion, and in cookies ,there is no problem, all memorable as it should be.
$select = array('RUB'=>",'USD'=>");
 if(isset($_POST['select'])) {
 setcookie("BX_CURRENCY",$_POST['select'], strtotime( '+30 days' ), SITE_DIR);
 $select[$_POST['select']] = 'selected';
 } elseif(isset($_COOKIE["BX_CURRENCY"])) {
 $select[$_COOKIE["BX_CURRENCY"]] = 'selected';
 <form method="post">
 <select class="form-control form-control-sm d-sm-none d-md-block" name="select" onchange="this.form.submit()">
 <option value="USD" <?=$select['RUB']?>>RUB</option>
 <option value="USD" <?=$select['USD']?>>USD</option>

Further there is a table where I need to output values depending on the selection in the selector, or if they are not in $_COOKIE, we show the default value if the $_COOKIE is an entry that derive from it.

if ($_POST['select']=="RUB") {
 echo $arItem["PRICES"]["Base"]["PRINT_VALUE"];
}elseif ($_POST['select']=="USD") {
 echo "$ ".round(CCurrencyRates::ConvertCurrency($val, "USD", "USD"), 2);

And then came the impasse, the POST works fine, add handling $_COOKIE begin to display repeated values ,if you set a default value so
if ($_POST['select']=="") {
 echo $arItem["PRICES"]["Base"]["PRINT_VALUE"];

It works but when you select in the selector POST zadavayte value so as to output the $_COOKIE need a page refresh...
Tried using switch\case ,is also not an option...
April 7th 20 at 15:32
1 answer
April 7th 20 at 15:34
Use of kernel methods for working with cookies

Find more questions by tags PHP