State servic eallow to store variables such as state of the server temporarily or permanently
Examples:
Read
A single value.
$val = \Drupal::state()->get('key');
Multiple key/value pairs.
$pairs = \Drupal::state()->getMultiple($keys);
Write
A single value.
\Drupal::state()->set('key','value');
Multiple values.
\Drupal::state()->setMultiple($keyvalues);
Remove
\Drupal::state()->delete('key');
More details : https://www.drupal.org/docs/8/api/state-api/overview
Comments