getCookieDomain static method
Retrieves the domain from the stored cookie.
Example:
lastCookieValue = "datadome=xxxx; domain=.example.com; path=/";
String domain = getCookieDomain(); // Returns ".example.com"
Returns the cookie domain as a String or an empty string if none is found.
Implementation
static String getCookieDomain() {
var lastCookieLowerCase = lastCookieValue.toLowerCase();
if (!lastCookieLowerCase.contains("domain=")) {
return "";
}
var domainSubstring = lastCookieLowerCase.split("domain=").last;
return domainSubstring.split(";").first;
}