DataScript: avi.http.add_cookie
DataScript
Function | avi.http.add_cookie( table ) |
Description | Insert a new cookie or cookies into the HTTP request or response. If the cookie already exists, Avi Vantage will append the specified value or flags to the existing cookie. |
Events | HTTP_REQ HTTP_RESP |
Parameter | A table of cookie name-value pairs for HTTP request contex) and optionally additional cookie attribute value pairs such as path, domain, etc for HTTP response. |
Request Parameter | HTTP Request event: The cookie name value pairs are added in the Cookie header of the HTTP request, and if no such header exists then the Cookie header is added. avi.http.add_cookie( name1, value1 [, name2, value2] ) name is the name of the new cookie. In the HTTP request context, all arguments are treated as cookie name value pairs, i.e. the function ignores cookie attributes such as "Domain", "Path", etc. and will treat them as another cookie to be added. |
Response Parameter | HTTP Response event: When called in an HTTP response context, the cookie name value pairs are added in the Set-Cookie header of the HTTP response. If no such header exists the Set-Cookie header is created. In the HTTP response context, only the first two arguments are treated as cookie name value pairs and the subsequent arguments are interpreted as cookie attributes such as Domain", "Path", etc. and their corresponding values. avi.http.add_cookie( name, value, path, domain, expires, maxage, httponly, secure ) name is the name of the new cookie. |
Returns | None |
HTTP Request Example | Example method 1: Add two cookies: jsessionid=123 and lang=en
Example method 2: Add two cookies: jsessionid=123 and lang=en
|
HTTP Response Example | Example 1: Add the cookie jsessionid with value 123, and attributes of path=/ and domain=www.avinetworks.com to produce the following header in the HTTP response: Set-Cookie: jsessionid=123; path=/; domain=www.avinetworks.com
Example 2: In this format, the order matters. The third argument must be path, fourth must be domain, fifth must be expires, sixth must be maxage, seventh must be httponly flag and the eighth must be secure flag.
If expires and maxage attributes are not desired, values 0 are passed as argument.
|