Time to upgrade! You only have until October 31, 2019 to move to Dynatrace, our all-in-one software intelligence platform. For details, see the Synthetic Upgrade Center and Dynatrace Synthetic documentation.

Validating if a cookie was set

The sample code below can be used to check all of the cookies that are currently set. In the code, we grab the cookies and store them all in siteCookie. We can then search for the name or value of a specific cookie to determine if it exists.

var loc = new Locator();
var currentWin = loc.findFrame('gomez_top[0]');
var siteCookie = currentWin.document.cookie;

alert ("Cookies received: " + siteCookie);

if ( siteCookie.indexOf("Gomez") != -1 )
	// Cookie was received
	// Skip validation action so the script can continue
	script.steps[1].actions[5].type = 'do not execute';
	alert ("Cookie was received");

A demo script can be downloaded: CookieValidationExample.gsl.