I need a way to store temporary data for anonymous users.

Apparently this is not possible with:

```
\Drupal::service('user.private_tempstore')

```

Unless you write a custom constructor for the session management and stuff, which seems a little far-fetched to me?

I tried using

```
\Drupal::service('user.shared_tempstore')

```

But that saves the temp data for all anonymous users. So it's not linked to a single user.

Using raw $\_SESSION['data'] works fine, but I'm not sure if I'm supposed to be doing this in Drupal and how safe/unsafe it is to do this?