Hello. There is a site where you need to organize the choice of the region. In php I'm new, maybe it will be a stupid bydlokod, better correct. How do I do: first we get the region that the user clicked on and output it in the URL:
<div id="rega"><a href="#" title="Vitebsk">Витебск</a> <a href="#" title="Mogilev">Могилев</a></div> $('#rega a').click(function() { var region = $(this).attr('title'); window.location.href = 'http://wp/?region=' + region; });
Then we get its name using PHP, save it in cookies and try to send the raw header:
<?php $defaultRegion = "Минск"; if(isset($_GET[region])) { $myRegion = $_GET[region]; setcookie("region", $myRegion, time()+3600); //Устанавливаем куки на регион header("Location: http://".$_SERVER['HTTP_HOST']."/".$myRegion); } ?>
Writes
Warning: Cannot modify header - it has already sent by (output started at ... \ header.php: 5) in ... \ header.php on line 28
How to achieve the necessary functionality, so that the user clicked on the link, the region was selected and it was saved in the cookie and the region did not change upon the subsequent location on the site?