Use of Drupal TempStore API
How to use Drupal TempStore API in application
TempStore API - A key/value storage to keep temporary data (private or shared) across page requests.
- Set value using Drupal service private_tempstore:
$tempstore = \Drupal::service('user.private_tempstore')->get('modulename');
$tempstore->set('key', 'Value to set');
- Get value using Drupal service private_tempstore:
$tempstore = \Drupal::service('user.private_tempstore')->get('modulename');
$myKey = $tempstore->get('key');
- By default it keep value stored a week long, while you can also delete value using delete function:
$tempstore = \Drupal::service('user.private_tempstore')->get('modulename');
$store->delete('key_name');
Comments
Post a Comment
There is comment posted on your blog, chandu7929@blogpost.com