If I want to set a variable that my whole controller can access, how do I do it?
Right now, in every function I am setting
$id = $this->session->userdata('id');
I’d like to be able to access $id from any function w/o defining it for each controller. 🙂
If there’s a better way, I’m all ears! I’m a noob!
To elaborate on Koo5’s response, you’ll want to do something like this:
See the manual for more information on PHP properties and constructors. Hope that helps!