Global variables are shared between all routes of an environment. Their values are reset when the environment is stopped or restarted.
⚠️These variables are not shared between environments.
Global variables are available everywhere templating helpers are supported. However, it makes most sense to use them in the response body.
💡 While you can use global variables in data buckets, keep in mind that bucket content will be generated when the server starts, when global variables are not yet set.
To set and access global variables, two templating helpers are available.
To set a global variable, use the
setGlobalVar helper. This helper takes two arguments: the variable name and its value. You can dynamically set the parameters using other helpers.
To get a global variable, use the
getGlobalVar helper. This helper takes two arguments: the variable name and an optional path. You can dynamically set the parameters using other helpers and use the fetched data in other helpers.