By editor, 26 November, 2020 Question How to stores and retrieves temporary data on session. This method allow to store data on drupal session using drupal session table (not php $_SESSION). Storage is different for each users ans each visitors if anonymous Store data $tempstore = \Drupal::service('tempstore.private')->get('mymodule'); $tempstore->set('var_name', 'Just test'); Get data $tempstore = \Drupal::service('tempstore.private')->get('mymodule'); $var = $tempstore->get('var_name'); Delete data $tempstore = \Drupal::service('tempstore.private')->get('mymodule'); $tempstore->delete('var_name'); CAUTION : The user.private_tempstore and user.shared_tempstore are now deprecated. Tags Drupal 8 Code Drupal 9 Cache Save a temporary data - Key Value Expirable. Comments You must have JavaScript enabled to use this form. Your name Subject Comment About text formats Plain text No HTML tags allowed. Lines and paragraphs break automatically. Web page addresses and email addresses turn into links automatically.
Comments