how to access session globally in web application

(S Padamwar) #1

HI everybody,

I am new in Yii framework,I am unable to access session globally in my web application i mean if i create session in site controller then i can access the session in same controller but i am unable to access session in different controller, Please help me

widget micro-controller
(Ivica Nedeljkovic) #2

I don’t see that you created session anywhere in SiteController.php file

(S Padamwar) #3

sorry i didn’t provided complete details

i have created session in useridentity

private $_id;

public function authenticate()













			$this->_id = $users->A_id;

			$session=new CHttpSession;//modified






		return !$this->errorCode;


by the way problem has been resolved now i am able to access session

public function accessRules()



    $session=new CHttpSession;//modified




     $name = $session['name'];


	return array(

		array('allow',  // allow all users to perform 'index' and 'view' actions




(Sharmakiran71) #4


You can use Yii session as,

Yii::app()->session[‘xyz’] = “value”;

and can use anywhere in site as,

echo Yii::app()->session[‘xyz’];

(Lparameshwarappa) #5

hi can anybody let me know how to display username of session once user login, in new page created in view/demo/ and i should insert in database if he create product.

(Lparameshwarappa) #6

got username but help me to insert his name into db along with the product he z adding., product z adding but hw to add username?