Share this page

# web.addCookieEx

Adds a cookie or cookies with the specified add behavior.

Cookie Functions

## Syntax

    web.addCookieEx( [{object},{object},...] );

## JavaScript Array of Objects

    [
     {
       insert: "<string>",
       allowEmptyDomain: "<string>",
       name:"<string>",
       value:"<string>",
       domain:"<string>",
       expires:"<string>",
       path:"<string>",
       secure:""
     }
    ]

For details on the elements of the Cookie, see Internet Standards Track document RFC6265.

Property Name | Description
--- | ---
Insert | Optional. Either "Default" or "Alt". If "Alt", the cookie is inserted as the first in the cookie table. Otherwise, it is inserted at the default location. The default is "Default".
allowEmptyDomain | Optional. Either "yes" or "no". If "yes", the domain element in the cookie can be empty. The default is "no".
name | The cookie name.
domain | The domain of the web server.
expires | The cookie expiration time.
path | The cookie path
secure | No value.

## Return Values

Not applicable

## Parameterization

The following argument(s) can be parameterized using standard parameterization: Cookie

## General Information

The web.addCookieEx function adds a new cookie or cookies with the option to place the cookie at the beginning of the cookie table, and to allow an empty domain. If the name and path match an existing cookie, the existing cookie is overwritten with the new one. If the "expires" date has past, the cookie is deleted.

Although scripts handle cookies automatically, there may be cases when you need to manually control the cookies.

Note: Scripts do not use (access or modify) the cookies that are stored by your browser. Instead, each script uses the cookies that are sent to the Vuser by the server host at runtime. These cookies are maintained only temporarily while the script runs. The web–cookie functions (web.addCookie, web.addCookieEx, web.removeCookie, and web.cleanupCookies) manipulate these temporary cookies only.

The intended use of web.addCookieEx is to add cookies usually stored in the browser, prior to starting the run.

## Example

    web.addCookieEx(
       [
        {
          name:"client_id",
          value: "China127B",
          path: "/",
          expires :"Wednesday,09-Nov-2020 23:12:40 GMT",
          domain : "www.mycompany.com",
          insert:'Alt',
          allowEmptyDomain:'yes'
         }
        ]
     );

Alternate form:

    web.addCookieEx(
       [{
         insert:'Alt',
         allowEmptyDomain:'yes',
         cookie: "Cookie=client_id=China127B; path=/; expires=Wednesday, 09-Nov-2020 23:12:40 GMT; domain="
       }]
    ));

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: