I added it to the Controller::init() and it was listed in Yii::app()->getEventHandlers(‘onEndRequest’)
public function init()
{
parent::init();
Yii::app()->onEndRequest = array(Yii::app()->session, 'close');
}
But it didn’t work.
So I overwrote method Controller::redirect()
public function redirect($url, $terminate=true, $statusCode=302)
{
if (Yii::app()->session->useCustomStorage) {
Yii::app()->session->close();
}
parent::redirect($url, $terminate, $statusCode);
}
strange thing… have exactly the same problem here: it looks like, new user session information/variables are lost after using redirect … if they are stored in the same action before redirecting.
I’m searching my source code since hours without success and now I find this post which absolutely fits my problem.
I’m writing data to an user session variables using
I setState & than redirect. the problem is the session is LOST!
its hard to reproduce, so i made a fix to the redirect function with session close and deploy to production. and i will see if the problem still exists.
thanks for the help guys, i will try to update
// EDIT ( 19/08/2014 )
this issue was not solved by session->close();
i am losing the session itself, not only the data inside it. it might be the cookie or something of that sort.