Global variables are variables that don't live on one particular channel — they pertain to all calls on the system. They have global scope. There are two ways to set a global variable. The first is to declare the variable in the [docs:globals] section of extensions.conf, like this:
You can also set global variables from dialplan logic using the GLOBAL() dialplan function along with the Set() application. Simply use the syntax:
To retrieve the value of a global channel variable, use the same syntax as you would if you were retrieving the value of a channel variable.