A
A
andruxin2014-04-22 21:52:32
Yii
andruxin, 2014-04-22 21:52:32

Yii. How to update the user's page transition time in the database?

The time of the last visit to the site.
I don't know where to put it. When authorizing, it is clear how to do this. The problem is that I don’t know where the cookie check of an already logged in user takes place, in order to write the time of the visit to the database after this check.
It would be desirable to inherit controllers and register in beforeAction last. Are there any other options?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
_
_ _, 2014-04-22
@AMar4enko

Em. CWebUser looks ingratiatingly in your direction. Inherit, register as a used class in the config, override init, first do parent::init(), then all user data will be available to you if he is not a guest. There you do everything you need. Session recovery occurs just in init.

N
Nokyta, 2014-04-23
@Nokyta

There is also another option, namely to save the session in the database. The CDbHttpSession class is responsible for this. We connect it in the config, configure it and know whose and when the session was created / updated. Everything depends on the task.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question