Show a country selection popup and save choice in Cookie

Show popup on page load

jQuery

<script>
  $(document).ready(function(){
    $("#myModal").modal('show');
  });
</script>
  • Save choice in cookie
<img src="uk.png" alt="Continue to our UK site" onclick="setCountryCookie('UK')" />
function setCountryCookie(country) {
  document.cookie = `fppCountry=${country}`
  countrySelector.hide();
}

Redirect to the site they selected

window.location.href = 'https://www.yoursite.com';

pass a value in header to the new site, check for it on the other site and if present add a cookie

window.location.search

"myCountry=UK; myName=Amna; myAge=31"

becomes

["fppCountry=UK", " myName=Amna", " myAge=31"]
matchString('myName is Amna', 'myName') // true
matchString('myName is Amna', 'thyName') // false