web_reg_add_cookie

Registers a search for a text string and adds a cookie if the text is found.

int web_reg_add_cookie( const char *cookie, const char *searchstring, LAST );
Argument
Description
cookie
Defines the cookie to add or modify. The Cookie parameter has the following format:
<name>=VALUE; (required)
domain=DOMAIN_NAME; (required)
expires=DATE;
path=PATH; (the default path is "/")
secure
The elements in the Cookie parameter are the same as the elements in the Set–Cookie HTTP Response Header. For details, see
http://wp.netscape.com/newsref/std/cookie_spec.html
For example, "Session=1234; domain=sanditon.com", where "Session" is the name.
searchstring
The text string for which to search. This attribute must be a non–empty, null–terminated character string. Use the format "Text=string".
LAST
A marker that indicates the end of the argument list.

Return Values

This function returns LR_PASS (0) on success, and LR_FAIL (1) on failure.

Parameterization

All arguments can be parameterized using standard parameterization.

General Information

The web_reg_add_cookie function registers a search for the text string specified by the searchstring argument. If the searchstring is found on the web page retrieved by the next action function, the specified cookie is added.

 

Note that, although web_reg_add_cookie is functionally similar to an HTTP Set_Cookie header, there is a significant difference. According to the HTTP standard, the domain attribute is optional in a Set–Cookie header from a server . If not specified, the default value of domain is the host name of the server that generated the cookie response. Since this information is not available to the load generator host when web_reg_add_cookie is called, the domain attribute is required.

This function can be used for both HTML–based and URL–based scripts (see Recording Options > Recording tab). It registers the search request before the buffers arrive, so the buffers are scanned as they come. This results in a more efficient script with better performance.

web_reg_add_cookie is added to the script by the user. It is not recorded.