CFileCache and redirect

Hi!

I’ve got a page that would redirect the user to another URL if that’s logged in. I’d like to use CFileCache to render the page faster if the user isn’t logged in.




array(

  'COutputCache + index',

  'varyByExpression'=>"PUSR()", // PUSR() function returns whether the user logged in

  'duration'=>43200, // 12 hours

),






    public function actionIndex() {

        if (PUSR()) {

            $this->redirect(Yii::app()->params->oldHomeUrl);

        }


        $this->render('index');

    }



But it doesn’t redirect the user that logged in. How could I fix this issue?

Hi. You must correctly call your function. For example:


 if (self::PUSR()) { 



or


 if ($this->PUSR()) { 

or


if (User::PUSR()) { 

Where is this function situated?

Hi,

Thanks for the answer! PUSR() is shortcut function!




globals.php


function PUSR() {

    return Yii::app()->getUser()->hasAuth();

}