Answer the question
In order to leave comments, you need to log in
Run a specific function when building a yii2 application?
The question may seem silly, but still I really want to ask it:
there is a certain function that pulls out a token and soap from cookies, checking it with the base, etc. and so on, in short, the mechanism of the checkmark with "remember" on the site. So, you need to run this function on every page of the site. Naturally, it’s even a no-brainer that calling it in every controller is idiocy... But where to call it once is no idea, and you can’t really stuff it into base classes, because it will swear at the namespace. How to decide, comrades-experts?
Answer the question
In order to leave comments, you need to log in
I would inherit all controllers, from the general one, and him from the base one. Then I would add beforeAction in the general controller and implement it in it. It is possible of course and in the main layout, but somehow not the MCV standard.
Use on beforeRequest in config:
stackoverflow.com/questions/28975197/set-yii2-catc...
www.yiiframework.com/doc-2.0/guide-structure-appli...
Maxim Timofeev has already answered everything for you, however, it is not clear why you fence your bike if Yii2 already has a similar "Remember" system built into the system?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question