Fortinet white logo
Fortinet white logo

Script Reference Guide

HTTP:get_session_id()

HTTP:get_session_id()

FortiADC will assign each session a unique ID and allow the user to get this unique ID through this function.

With this unique ID, the user can use Lua scripts to capture request headers, store them into a global variable indexed by this unique ID, and then index a global variable using this unique ID to extract its own request header information in the HTTP request event.

Syntax

HTTP:get_session_id();

Arguments

N/A

Events

Applicable in the following events:

  • HTTP_REQUEST

  • HTTP_RESPONSE

  • HTTP_DATA_REQUEST

  • HTTP_DATA_RESPONSE

Example

When RULE_INIT{
Env={}
}
when HTTP_REQUEST{
id=HTTP:get_session_id()
debug("session id %d\n", id);
env[id]=nil
req={}
req["url"]=HTTP:uri_get()
req["method"]=HTTP:method_get()
env[id]=req
}
when HTTP_RESPONSE{
id=1
request=env[id]
if req then
debug("session id %d and url %s\n", id,request["url"]);
debug("session id %d and method %s\n", id,request["method"]);
end
}
Output:
session id 1
session id 1 and url /index.html
session id 1 and method GET

Supported Version

FortiADC version 4.8.x and later.

HTTP:get_session_id()

HTTP:get_session_id()

FortiADC will assign each session a unique ID and allow the user to get this unique ID through this function.

With this unique ID, the user can use Lua scripts to capture request headers, store them into a global variable indexed by this unique ID, and then index a global variable using this unique ID to extract its own request header information in the HTTP request event.

Syntax

HTTP:get_session_id();

Arguments

N/A

Events

Applicable in the following events:

  • HTTP_REQUEST

  • HTTP_RESPONSE

  • HTTP_DATA_REQUEST

  • HTTP_DATA_RESPONSE

Example

When RULE_INIT{
Env={}
}
when HTTP_REQUEST{
id=HTTP:get_session_id()
debug("session id %d\n", id);
env[id]=nil
req={}
req["url"]=HTTP:uri_get()
req["method"]=HTTP:method_get()
env[id]=req
}
when HTTP_RESPONSE{
id=1
request=env[id]
if req then
debug("session id %d and url %s\n", id,request["url"]);
debug("session id %d and method %s\n", id,request["method"]);
end
}
Output:
session id 1
session id 1 and url /index.html
session id 1 and method GET

Supported Version

FortiADC version 4.8.x and later.