Why User Session Is Empty In My Controller?

I have the below controller for Admin Auth. I could not get the user session ID here, how can i get it? only this place it is not showing the session… when I go other controllers, it displays

Original Admin Controller Class




class AdminController extends CController

{

    /**

     * @var string the default layout for the controller view. Defaults to '/layouts/column1',

     * meaning using a single column layout. See 'protected/modules/admin/views/layouts/column1.php'.

     */

    public $layout = '/layouts/column2';


    /**

     * @var array the breadcrumbs of the current page. The value of this property will

     * be assigned to {@link CBreadcrumbs::links}. Please refer to {@link CBreadcrumbs::links}

     * for more details on how to specify this property.

     */

    public $breadcrumbs = array();




    /**

     * @var array admin context menu items. This property will be assigned to {@link TbMenu::items}.

     */

    public $adminMenu = array();


    /**

	 * @return array action filters

	 */

	public function filters()

	{

		return array(

			'accessControl', // perform access control for CRUD operations

			'postOnly + delete', // we only allow deletion via POST request

		);

	}


	/**

	 * Specifies the access control rules.

	 * This method is used by the 'accessControl' filter.

	 * @return array access control rules

	 */

	public function accessRules()

	{

		return array(

			array('allow',  // allow Admin users to perform all actions

				'expression' => array('AdminController','isAdministrator'),

			),

			array('deny',  // deny all users

				'users'=>array('*'),

				'deniedCallback' =>array($this,'redirectToLogin'),

			),

		);

	}

	

	public static function isAdministrator() 

	{

            $user = User::model()->find(array('condition'=>'userType=:userType ', 'params'=>array(':userType'=>'Administrator'), 'select' => 'id'));

            

            echo 'xx 1: '.Yii::app()->user->id;

            echo '<br> xx 2: '.Yii::app()->getId();

                        

            exit;

            

            if( Yii::app()->user->id === $user->id )

            {

                return true;

            }

            else

           {

                return false;

            }  

            

            //return true;

	}


    public function redirectToLogin() 

	{ 

		Yii::app()->user->setFlash('error','You must login to access.');

		Yii::app()->controller->redirect(array ('/admin/login','returnUrl'=>Yii::app()->request->url)); 

	}

    



Hi,

It should extends Controller not CController

I have doubt on this point… check that :)

did you try $this->ID ?

show it to see.

echo($this->ID);