Hi there guys…
I’ve been strugling looking for a way to set a cookie if a URL parameter is persent. The problem is, the name of the URL parameter is half dynamic.
The URL would be: “
The XXXX is the userID that will change depending on the customer and YYYY is the actual value (transaction number).
I have the following code but it won’t recognize the brakets nor what is inside. How can I set it to recognize the URL parameter including the brakets and the dynamic userID within the brakets?
====================================================
function URLparam(name) {
return unescape(
(RegExp(name + ‘=’ + ‘(.+?)(&|$)’).exec(location.search)||[,null])[1]
);
}
if (URLparam(“transaction”) !== null && !get_cookie (“Transacion_ID”)) {
set_cookie (“Transacion_ID”, URLparam(“transaction”));
}
if (get_cookie (“EX_Transacion_ID”)) {
console.log(get_cookie (“transaction”));
}
});
====================================================
Any hint would be much appreciated.
Thanks!