You are browsing the documentation for Symfony 4.0 which is not maintained anymore.
Consider upgrading your projects to Symfony 5.2.
Symfony provides a nice session object that you can use to store information about the user between requests.
To see how to use the session, read Managing the Session.
More about Sessions¶
This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.