Plesk key-value storage is used for storing user settings or secret
keys. To access the Plesk key-value storage, use the
pm_Settings
class. Keys and values are stored in the context of an extension.
If you need to assign a variable, use the method
pm_Settings::set('authToken', $authToken);
Special case:
pm_Settings::set('something', null);
Note: Before Plesk 17.0, this statement would result in an exception to be
thrown. Beginning with Plesk 17.0, this statement will cause the
corresponding element to be removed from the key-value storage.
Now you can retrieve the value of this variable by using the method
$authToken = pm_Settings::get('authToken');
An additional optional parameter can be used to specify a default value
to be returned in case the corresponding key is not found:
$message = pm_Settings::get('message', 'default message');
To obtain access to them in some places of code, initialize the context
first:
pm_Context::init('extension-id');
It is mandatory to initialize the context in the following places in
code:
- Scheduled tasks.
- Post- and Pre- installation scripts.
- Event handlers.…