O Connor
O Connor

Reputation: 4412

How to update User status after automatically logout on Yii framework 2 when user is inactive for awhile?

On Yii framework 2, I set the User status to 1 after logging in and to 2 after manual logging out as following.

//after logging in
$user->status = 1; 
$user->save(true, ['status']);

//after manual logging out
$user->status = 2; 
$user->save(true, ['status']);

But Yii framework 2 has a mechanism to automatically clear the login session after user is inactive for awhile. How can I then update the User status in this case?

Upvotes: 0

Views: 474

Answers (1)

user7242866
user7242866

Reputation:

Do it in afterLogout() method in class inherited from Yii\web\User?

Upvotes: 1

Related Questions