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.