SetServerVar

The SetServerVar function creates a server-wide global variable in a policy.

It can be accessed by any functions and exception handlers, like a global variable created by SetGlobalVar(). Unlike in SetGlobalVar() calls, however, all threads running the same policy will share the same copy of the global variable. So if one thread running the same policy changes the variable value, the change is visible to all other threads running the same policy.

Syntax

SetServerVar(variablename, variablevalue)

Parameters

Table 1. SetServerVar function parameters

Parameter

Description

variablename

Name of the variable.

variablevalue

Initial value of the variable.

Examples

Here are examples of policies that use the SetServerVar and GetServerVar functions:

//Policy 1
function SaveServerVarTest(){
flag = "THIS FLAG DENOTES A SERVERVAR";
SetServerVar("runTimeFlag", flag);

Activate(null, 'Policy2');
}

function GetServerVarTest(){
Log("runTimeFlag = " + GetServerVar("runTimeFlag"));
}

//Policy2
Log("runTimeFlag = " + GetServerVar("runTimeFlag"));