You can set site variables for each site managed by Site Factory. Site variables can be removed as part of the staging process if they contain sensitive data, such as API keys.
Site variables are available for Site Factory sites according to the following requirements:
- Each site can have a maximum of 10 site variables defined.
Any of the site variable keys must not contain any spaces.
- Each site variable key can have a maximum length of 25 characters.
- Each site variable value can have a maximum length of 50 characters.
When managing site variables, review the following expected functionality:
- Site variables are not copied between sites when a site is duplicated.
- Selecting the Remove during staging checkbox when defining a site variable removes the site variable from the site when staging it to a lower environment. The production environment is unaffected.
- After you add a new site variable, the system might take a few minutes to make the site variable available on the site.
- If you do not select the Wipe target environment option, Site Factory does not copy site variables during the stage down process as they are part of Factory database and not the site database.
Creating site variables
Using the site variable in the site code
You can access defined variables within the site code using the following variable:
$GLOBALS['gardens_site_settings']['flags']
```
Example array:
```
array(3) {
["external_service_api_key"]=>
string(13) "apikey-value2"
["non-secret-key"]=>
string(7) "value-2"
["external_service_api_key_non-secret"]=>
string(19) "apikey-value xx1234"
}
```