Sticky Page Cache

Hi,

I am using the Cage Cache Filter for my Site Controller.


public function filters()

{

	return array(

		array(

			'COutputCache + page, index',

			'duration' => 100,

			'varyByParam' => array('view'),

			'varyBySession' => true,

		),

	);

}

I modified my login and logout with session regenerate, so varyBySession works


function actionLogin()

{

	....

	Yii::app()->session->regenerateID(true);

	....

}


public function actionLogout()

{

	Yii::app()->user->logout();

	Yii::app()->session->regenerateID(true);

	$this->redirect(Yii::app()->homeUrl);

}

This works great for the following:

  • Enter the site anonymous

  • see logged out state navigation

  • login

  • see logged in state navigation

But if I now logout the navigations stays in the logged in state? What’s wrong?

P.S.: How can I make the [code]-Tag highlight my PHP snippets?

P.P.S.: Forget that one, this works after posting but not in post preview

I ran into a problem once were session id’s where not being regenerated correctly. Maybe check your user is getting a new id on logout.


print Yii::app()->getSession()->getSessionID();


string(12) "before login" string(26) "8rl8jrjl2k5hi2iimge37h8613"

Yii::app()->session->regenerateID(true);

string(11) "after login" string(26) "6t7ulhq87vmfdfd42camsqr8e6"


string(18) "before user logout" string(26) "6t7ulhq87vmfdfd42camsqr8e6"

Yii::app()->user->logout();

string(13) "before logout" string(0) "" 

Yii::app()->session->regenerateID(true);

string(12) "after logout" string(0) ""

Great. Looks like

a ) user->logout destroys my session

b ) caching does not work with empty session ids…

If I add


Yii::app()->session->open();

Everything is fine… strange.