TASIOMIND.DEV — OPERATIONAL▸▸▸FULL STACK DEVELOPER @ GWQ SERVICEPLUS AG▸▸▸FOUNDER — K8SGPT.AI▸▸▸OPEN SOURCE: ACTIVE▸▸▸DISTRIBUTED SYSTEMS / KUBERNETES / AI▸▸▸RUST + GO + PYTHON▸▸▸FIELD TESTED / STATUS — NOMINAL▸▸▸LOCATION: EUROPE/BERLIN▸▸▸TASIOMIND.DEV — OPERATIONAL▸▸▸FULL STACK DEVELOPER @ GWQ SERVICEPLUS AG▸▸▸FOUNDER — K8SGPT.AI▸▸▸OPEN SOURCE: ACTIVE▸▸▸DISTRIBUTED SYSTEMS / KUBERNETES / AI▸▸▸RUST + GO + PYTHON▸▸▸FIELD TESTED / STATUS — NOMINAL▸▸▸LOCATION: EUROPE/BERLIN▸▸▸

Show a country selection popup and save choice in Cookie

March 26, 2020

Show popup on page load

jQuery

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

Redirect to the site they selected

code
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

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

becomes

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