Drupal 9: Get And Set Data In Drupal Private Temporary Store

Set:

/** @var \Drupal\Core\TempStore\PrivateTempStore  $store */
$store = \Drupal::service('tempstore.private')->get('mymodule');
$store->set('var_name', $data);

Get:

/** @var \Drupal\Core\TempStore\PrivateTempStore  $store */
$store = \Drupal::service('tempstore.private')->get('mymodule');
$data = $store->get('var_name');

Add new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
4 + 0 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.