Application variable best practice

Notice: This thread is very old.
unagi2020
Member | 18
+
0
-

I want to set certain variables based upon login url which will be used in various methods across the application. What is the best practice for declaring such a variable?

HosipLan
Moderator | 4668
+
0
-

If the variable would be in the URL, then use persistent parameters in BasePresenter. Otherwise, i would use Nette\Http\Session, or you can even store data in user's Identity object.

If you tell us what kind of data for what kind of methods, we would be able to give you a better answer.

unagi2020
Member | 18
+
0
-

Thank you for the answer. I want to set a some environment variables for enabling and disabling function level profiling. I am currently using Identity object for storing those variable. I wanted to check if there is an other application object besides Identity object for storing such information.

I was not sure if storing application level variable in Identity object was a best practice.

HosipLan
Moderator | 4668
+
0
-

Well, I personaly think that best practice would be to create some storage for variables of this kind.

And sidenote: relying on some secrect keys in URL, for enabling something is not safe.