// ONLY FOR LOGGEDIN USER
// For "mymodule_name," any unique namespace will do.
// I'd probably use "mymodule_name" most of the time.
$tempstore = \Drupal::service('user.private_tempstore')->get('mymodule_name');
//or
$tempstore = \Drupal::service('user.shared_tempstore'))->get('mymodule_name');
$tempstore->set('my_variable_name', $some_data);
$some_data = $tempstore->get('my_variable_name');