April 25, 2012

I want to define variable in CodeIgnitor so that it can be accessed in application

Question by Musaddiq Khan

e.g array of constants so that it can be accessed in controllers, views, models.
Thanks

Answer by Starx

If you are looking for globally accessible datas, then session is more than just a storage feature.

Set the session values like this

$this->session->set_userdata('item', 'value');

And read the values like this

$this->session->userdata('item');

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!