Yii->user->id is null in controller after susccful aythentication

I m new to yii .

i have created an application which has admin panel

I have used Webuser for authentication

My directory Structure is

controller/

-> frontend

---->SiteController.php

->backend

----->SiteController.php

…same for views…

See UserIdentity.php

class UserIdentity extends CUserIdentity {

const ERROR_EMAIL_INVALID=3;


public $id;








public function authenticate() {


    $record = User::model()->findByAttributes(array('username' => $this->username));





    if ($record === null) {


        $this->errorCode = self::ERROR_USERNAME_INVALID;


    } elseif ($record->password !== md5($this->password) and $record->password !== $this->password) {


        $this->errorCode = self::ERROR_PASSWORD_INVALID;


    } else {


		$this->username = $record->username;


        $this->id = $record->id;


		$this->setStates($record);


		$this->errorCode = self::ERROR_NONE;


	}


	


    return!$this->errorCode;


}





public function getId() {


    return $this->id;


}





private function setStates($user) {


    $this->setState('rank', $user->group_id);


    $this->setState('email', $user->email);


	


}

}

and WebUser.php

<?php

class WebUser extends CWebUser {

public &#036;email;


public &#036;rank = 1;





public function init() {


    parent::init();





    /*


     * Sets the user email and rank


     * The reason I use this method is so that I can access the user states as attributes (you can do that anyways as of Yii 1.0.3 though)


     * and so that the user rank defaults to 1 (meaning not logged on)


     * See the group model for information on the ranks


     */


    &#036;this-&gt;email = &#036;this-&gt;getState('email');


    &#036;rank = &#036;this-&gt;getState('rank');


    if (&#036;rank &#33;= null)


        &#036;this-&gt;rank = &#036;rank;


}





/**


 * Compares the current user to &#036;rank


 *


 * Should be used in view to decide if e.g. an admin-only link should be rendered


 * Example:


 * &lt;?php if (Yii::app()-&gt;user-&gt;hasAuth(Group::ADMIN, 'min')){ ?&gt;


 * 	&lt;p&gt;Something only an admin or higher ranking user should see&lt;/p&gt;


 * &lt;?php } ?&gt;


 *


 * This is a very simple yet fairly flexible authorization technic.


 * Note I have also extended the AccessControlFilter to be simpler and yet also


 * reasonably flexible


 *


 * @param integer the rank to campare the current user to


 * @param string the camparison type.  Can be 'min', 'max', or 'equal'


 */


public function hasAuth(&#036;rank = 2, &#036;comparison = 'min') {


    &#036;mapConditions = array(


        'min' =&gt; (&#036;this-&gt;rank &gt;= &#036;rank),


        'max' =&gt; (&#036;this-&gt;rank &lt;= &#036;rank),


        'equal' =&gt; (&#036;this-&gt;rank == &#036;rank),


    );


    return &#036;mapConditions[&#036;comparison];


}

}

?>

AND model/User.php

public function authenticatePass($attribute,$params) {

	if (&#33;&#036;this-&gt;hasErrors()) { // we only want to authenticate when no input errors


		&#036;identity = new UserIdentity(&#036;this-&gt;username,&#036;this-&gt;password);


		&#036;identity-&gt;authenticate();


		


		switch (&#036;identity-&gt;errorCode) {


			case UserIdentity::ERROR_NONE:


				&#036;duration = &#036;this-&gt;rememberMe ? 3600*24*30 : 0; // 30 days


				Yii::app()-&gt;user-&gt;login(&#036;identity, &#036;duration);


				break;


				


			case UserIdentity::ERROR_USERNAME_INVALID:


				&#036;this-&gt;addError('username','Nom d&#092;'utilisateur est incorrect.');


				break;


				


			case UserIdentity::ERROR_EMAIL_INVALID:


				&#036;this-&gt;addError('username','Vous devez valider votre adresse e-mail avant de vous connecter.');


				break;


				


			default: // UserIdentity::ERROR_PASSWORD_INVALID


				&#036;this-&gt;addError('password','Mote de passe est incorrect.');


				break;


		}


	}


}

I have used widgets UserLogin.php

class UserLogin extends Portlet {

public &#036;title = '';





protected function renderContent() {


    &#036;form = new LoginForm;


    if (isset(&#036;_POST['LoginForm'])) {


        &#036;form-&gt;attributes = &#036;_POST['LoginForm'];


        if (&#036;form-&gt;validate()) {


            &#036;userConnected = User::model()-&gt;find('username = :un', array('un' =&gt; &#036;form-&gt;username));


			if (&#036;userConnected &amp;&amp; (&#036;userConnected-&gt;group_id == Group::ADMIN || &#036;userConnected-&gt;group_id == Group::SITE_ADMIN)){


                &#036;this-&gt;controller-&gt;redirect(array('home/index'));


            }elseif( &#036;userConnected-&gt;group_id == Group::AGENCE){


                &#036;this-&gt;controller-&gt;redirect(array('site/index'));


            }


        }//if


    }


    &#036;this-&gt;render('userLogin', array('form' =&gt; &#036;form));


}

}

Here everything is correct…i mean username and password are correct

when i check in homeController/actionIndex Yii::app()->user->id is empty and it display the Login form

i have two files for frontend and backend

for

http://myhost.com/

front.php

‘components’=>array(

		'urlManager'=&gt;array(


		'urlFormat'=&gt;'path',


		'rules'=&gt;array(


			'&lt;controller:&#092;w+&gt;/&lt;id:&#092;d+&gt;'=&gt;'&lt;controller&gt;/view',


			'&lt;controller:&#092;w+&gt;/&lt;action:&#092;w+&gt;/&lt;id:&#092;d+&gt;'=&gt;'&lt;controller&gt;/&lt;action&gt;',


			'&lt;controller:&#092;w+&gt;/&lt;action:&#092;w+&gt;'=&gt;'&lt;controller&gt;/&lt;action&gt;',     


		),


	  ),


	),

http://myhost.com/admin/

back.php

‘components’=>array(

		'urlManager'=&gt;array(


			'urlFormat'=&gt;'path',


			'rules'=&gt;array(


				'admin'=&gt;'site/index',


				'admin/&lt;controller:&#092;w+&gt;/&lt;id:&#092;d+&gt;'=&gt;'&lt;controller&gt;/view',


				'admin/&lt;controller:&#092;w+&gt;/&lt;action:&#092;w+&gt;/&lt;id:&#092;d+&gt;'=&gt;'&lt;controller&gt;/&lt;action&gt;',


				'admin/&lt;controller:&#092;w+&gt;/&lt;action:&#092;w+&gt;'=&gt;'&lt;controller&gt;/&lt;action&gt;',     


			),


	  ),


	),

main config file

main.php

‘import’=>array(

	'application.models.*',


	'application.components.*',


	'application.components.widgets.*',


	'application.controllers.AdminController',


    'application.extensions.*',


	#user module starts


),

‘components’=>array(

   		'user' =&gt; array(


        'class' =&gt; 'WebUser',


		// enable cookie-based authentication


      	//  'allowAutoLogin' =&gt; true,


        'loginUrl' =&gt; array('user/login'),


		


        ),

I m not getting where is the problem exists…

plz i need help urgent