Synthetic Classic has reached end of support and is no longer available. Existing Synthetic Classic customers have been upgraded to the all-in-one Dynatrace software intelligence platform.

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.