umaxim
asked on
hooks CodeIgniter
Hi i create a hook file with mysql query in CodeIgniter so it take some information like configuration from there like name of the website some staff. How i can send this data to controllers so i can use it in future for example to put on template or just to give some access to some controller.
You might try putting the information into the $_SESSION array. That is how most data is carried from request to request.
ASKER
no hook run before controller so i need just to save it in some global variable.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You did not understand i did not change page i just load hook before all different controller load. So i load it and then controller load. But i want to load in hook my configuration in some array so i can use it latter when begin controller load. It the same page. I did not need to change page and save it for next page.
@Ray,
$_SESSION does not work as expected in CI as CI has its own session class, that will pull all data out of the $_SESSION array see -> http://codeigniter.com/user_guide/libraries/sessions.html So while your solution is the way I would do it, its done a little differently in CI, using $this->session->set_userda ta as mentioned in the link I posted.
@umaxim he was giving you a proper solution, you are asking "How can I set this, so that I can later access it" which is exactly what sessions are for! Please see the CI manual for how to do this with CI. The manual is your friend and CI is extremely well documented.
$_SESSION does not work as expected in CI as CI has its own session class, that will pull all data out of the $_SESSION array see -> http://codeigniter.com/user_guide/libraries/sessions.html So while your solution is the way I would do it, its done a little differently in CI, using $this->session->set_userda
@umaxim he was giving you a proper solution, you are asking "How can I set this, so that I can later access it" which is exactly what sessions are for! Please see the CI manual for how to do this with CI. The manual is your friend and CI is extremely well documented.