Calling a function on each page |
[eluser]Grim[/eluser]
Hey all started using CI a few weeks ago, and is swapping out old code with it :-) But a small snag I've hit is that before I used to have a PHP file called startsession.php which is called on every page to start the session and set vars if there is cookies available. Code: <?php So I have a controller named auth and have a function called auto_login which does the same thing but how do I call it on every page ? Sorry If its a little redundant :blank: Thanks In Advance :-)
[eluser]rogierb[/eluser]
you can do this by extending the CI_controller Read up on it at http://ellislab.com/codeigniter/user-gui...asses.html You extend the controller so you can load your own functions. Dont forget to call your new controller (MY_controller) instead of the CI_Controller
[eluser]Grim[/eluser]
[quote author="rogierb" date="1347623862"]you can do this by extending the CI_controller Read up on it at http://ellislab.com/codeigniter/user-gui...asses.html You extend the controller so you can load your own functions. Dont forget to call your new controller (MY_controller) instead of the CI_Controller[/quote] Thanks! It Worked and sorry for the late reply. And also, I extended the controller. And is it okay to use $this->data->varname directly in the view file. Instead of passing it through $data['varname'] ? |
Welcome Guest, Not a member yet? Register Sign In |