Session Disappear After Page redirect in Controller Init()

I am having 2 Yii projects.

Project A will call Project B to handle user login and logout.

When logout, Project A will redirect to Project B, then come back to Project A again.

There are some global setting in components/Controller.php public function init(), to assign default value to session, like website language. ( work like hooks )

There is no issue for Login.

When logout and come back to Project A, session will be empty which I have tried to print $_SESSION at the end of Controller init().

And this cause error to my site index.

Once I refresh the same page, it will back to normal and default session appear.

I have checked the SESSION ID in browser cookie, it does not changed.

Could anyone please help to solve this problem?

Thank You!

I have the same problem.

How to solve it, please?

That’s the way I dealt with:

class Controller extends CController


    public function redirect($url, $terminate=true, $statusCode=302)


        if(session_id()!=='') @session_write_close();

	parent::redirect($url, $terminate, $statusCode);