I have an API with laravel 5.6 and I need to create global variables that throughout the application can have their value changed, however I am having problems.
Example: - At the first request, the value of this variable as "test"; - In the second request I want to get the current value, which should be "test";
- I tried initially to use the config, but it did not work;
- I tried to use Session, but I had the same problem;
- I tried to set a variable in the "super controller", where all controllers extended to it, it did not work.
The value of the variable is only valid during the execution of the request, that is, I make a request to the controller aaaControler, this makes use of other controllers, within the same request the value persists, but ends in the return.
I thought of persisting in the database, creating a reference and always fetching this value there, but will this be the best way?
I ask for help in this matter.
Thank you.