2

I have a form for anonymous user some steps before the user registers. I save the data in the PrivateTempStore. A final step is to register and log in. But when a user is logged in, the PrivateTempStore seems emptied automatically.

I want to attach the previously saved data in the PrivateTempStore to my new logged in user, what is the best practice to do this?

Right now I am saving the data to extra hidden fields in the register form, but this seems overkill.

3
  • 2
    Why you need a private tempstore for anonymous users? The private tempstore depends on a session id, so you can store the data in the session as well, unless you have megabytes of data. The session data itself is transferred automatically when the user logs in.
    – 4k4
    Dec 13 '19 at 9:58
  • Thanks, interesting answer. But when is a PrivateTempStore necessary then? I do not see a big difference with sessions. Dec 13 '19 at 10:09
  • See drupal.stackexchange.com/questions/278686/…
    – 4k4
    Dec 13 '19 at 10:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.