First I want to say that i am really new in programming yii1.I have to catch the event when session is destroyed or closed in yii1 and redirect to index when the event is triggered.
I've tried to extend CHttpSession class and extend the method sessionDestroy(), but i miss something because my solution is not working.
My class that extends CHttpSession that is located in components folder:
class SessionDestroy extends CHttpSession {
public function destroySession($id) {
Yii::log('destroy', 'info');
$result = parent::destroySession($id);
return $result;
}
}
Then in my controller i have:
$session = new CHttpSession;
$session->open();
...
$session->destroy();
I expect to see in log the destroy info message but nothing happens.
Extending part is right. Then you need to configure session
component to use your new class:
'components' => [
// ...
'session' => [
'class' => 'SessionDestroy',
],
]
See https://www.yiiframework.com/doc/guide/1.1/en/basics.application#application-components