DataScript: avi.http.cookie_exists

DataScript

Function avi.http.cookie_exists( name, [context] )
Description Returns true if the cookie name exists in the HTTP request or response. The context determines the req/resp, when no context is specified the default context is based on the event the DataScript was executed from.
Events HTTP_REQ
HTTP_REQ_BODY
HTTP_RESP
Parameter name is a string specifying the cookie name.
context : Rather than inspect the cookie from the current event context, specify the context of either avi.HTTP_REQUEST or avi.HTTP_RESPONSE to inspect cookies from those events.
For instance, during an HTTP response event, check for a cookie sent by the client during the request event.
Note : You cannot provide avi.HTTP_RESPONSE as the context argument to get_cookie if calling the function in HTTP_REQ or HTTP_REQ_BODY events
Returns Boolean true if the cookie name exists else false.
Example If the ServerIP cookie exists, send the request to the server IP address defined within the cookie.
if avi.http.cookie_exists("ServerIP") then
   avi.pool.select("Pool1", avi.http.get_cookie("ServerIP"))
end