Restoring tempstore with another session ID I am building the functionality of sign in during payment checkout in Drupal 8, and I am storing all the values in Drupal 8's tempstore variable. I am capturing the session id for this anonymous user. After the user is signed in, his session ID changes, and I am not able to load the tempstore with the session ID of anonymous user. Is there a way to restore the private tempstore by another tempstore session ID?

So, the submit function of my custom sign in form looks something like this:

$anonymous_session_id = session_id();

$user = user_load_by_mail($form_state-&gt;getValue('username'));
$uid  = $user-&gt;get('uid')-&gt;value;
user_login_finalize($user);

$temp_store = \Drupal::service('user.private_tempstore')-&gt;get($anonymous_session_id . '_com_reg');


When I do $temp_store-&gt;get('some_value'); it does not give me any result since I am not able to restore the values. Can someone please help in this?
I've experienced the same issue while trying to pass private.tempstore data through anonymous to authenticated user in Drupal 8. 

The function 

user_login_finalize($user); 

Performs de migrate() method. This method migrates anonymous session to authenticated session, but only the Native Session Storage (Symfony).

Private.tempstore has to manually be migrated as Ekta tells.

If you can't or you d'ont know how to implement it, just store the data in native $_SESSION['yourkey']

The problem it's that native Session it's loaded every time a page it's called, and with Tempstore you have more control about this. For this reason it's not the better solutions!.

This could be a good issue for Drupal Core in a future, migrate the tempstore too when session login.