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.

Setting multiple cookies

If you have numerous scripts that cookies need to be set for, you can do this by creating an event hook that will attach a list of cookies to a request.

In the code, the variable cookieValues is created that can contain as many cookies as needed. The event hook then attaches the cookies to whichever URL you specify.

cookieValues = "cookie1=value1; " +
 "cookie2=value2; " +
 "cookie3=value3; " +
 "cookie4=value4; ";
 var send = new AddEventHookCommand({
 "eventType": "sendingRequest",
 "name": "setCustomCookie",

"handler":"if(request.getUrl() == 'http://www.dynatrace.com/'){
alert('Setting Cookies'); var headers = request.getHeaders();
headers.replace('Cookie', cookieValues); }"
 });
 send.execute();

A demo script can be downloaded: setCookies.gsl.