session - Codeigniter: Set 'global variable' -


If I want to set a variable that can use my entire controller, how can I do this?

Right now, in every function I

  $ id = $ this-> session-> Setting user data ('id');  

I want to be able to access any work w / o to $ id from each controller that defines it. :)

If there is a better way, then I'm all ears! I'm a Noble!

To expand, you want to do something like this:

  Class extends yourController controller {// This is a property, public $ id = null accessible from any function in this category; // This is the constructor (outlined by Koo5) function __construct () {// like this you $ id within $ $ class - this-> Id = $ this- & gt; Session-> Refer user data ('id'); } Function getID () {// $ ID property return $ - this-> id; }}  

See the manual for more information about PHP. Hope that helps!


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -