<script>(function() {
// function to get GET variables from the address bar
function getParameterByName($from, $name) {
let match = RegExp(`[?&]` + $name + `=(?!=&)([^&]*)`).exec($from);
return match && decodeURIComponent(match[1].replace(/\+/g, ` `));
}
// start recording an array with site sorting data and GET variables upon detecting sort_by
let $from = window.location.href;
if (getParameterByName($from, "sort_by") !== null) {
let $hotengine_cookie_conv_to_get = [
{"sort_by": getParameterByName($from, "sort_by")},
{"order_by": getParameterByName($from, "order_by")},
{"order_by_param": getParameterByName($from, "order_by_param")},
{"shop_new_goods": getParameterByName($from, "shop_new_goods")},
{"shop_sale": getParameterByName($from, "shop_sale")},
{"shop_bestsellers": getParameterByName($from, "shop_bestsellers")},
{"shop_discount": getParameterByName($from, "shop_discount")},
{"shop_reduced_price": getParameterByName($from, "shop_reduced_price")},
{"sort_instock_priority": getParameterByName($from, "sort_instock_priority")},
{"price_from": getParameterByName($from, "price_from")},
{"price_to": getParameterByName($from, "price_to")},
{"NUM_ONPAGE": getParameterByName($from, "NUM_ONPAGE")},
{"smart_search": getParameterByName($from, "smart_search")},
{"search": getParameterByName($from, "search")},
];
// record Cookie with data in JSON format
document.cookie = `hotengine_cookie_conv_to_get=${JSON.stringify($hotengine_cookie_conv_to_get)}; path=/; max-age=31536000;`;
}
// to delete Cookie use document.cookie=`hotengine_cookie_conv_to_get=; path=/; max-age=0;`;
})();
</script>
» and others are extracted from the address bar. The data is written to Cookie in JSON format. Then, when opening pages later, the site, upon detecting the Cookie «
», converts the array names (indices) into GET variables with the corresponding indices and values. Thus, having selected the site sorting once, the visitor will see it until the Cookie is changed.