Drupal 8 – Alter session variable without redirecting the page

I’m looking for a solution to change a Drupal Session Variable (PrivateTempStoreFactory) without redirecting to another page. I can accomplish altering the variable by using routing.yml in my module, but this is not a solution that is effective as it changes to a different path.

Simply put, I am trying to create a Role menu in which a User can select an available role that has been assigned to them. When they select a role, their role should be updated in the session and redirected back to the page they started the action (Menu and other things may change, hence the page needs to be reloaded).

Any help would be appreciated! I’m learning Drupal 8 and it’s been quite the curve!

Drupal version: 


Source: https://www.drupal.org/taxonomy/term/4/feed