OpenSIPS has several types of variables and vectors. Each type of variable has a different scope. Note that PV has the scope of a process and AVP has the scope of a transaction. Thus, if you need a variable that is capable to persist the whole duration of the call from the first INVITE to the end BYE, you will need dialog variables. You can also use flags, which are simpler.
There are strict rules with regard to the dialog variables. You can set a dialog variable after creating a dialog in the initial request. You can only read a dialog variable after a dialog matching command such as loose_route()
or match_dialog()
.
To attach a value to a dialog, you can use the store_dlg_value(name,val)
function or directly set the variable using $dlg_val(name)
. See the following examples:
store_dlg_value("type","residential"); # or $dlg_val(type) = "residential";
To recover and/or set a dialog variable, you can again use the fetch_dlg_value...