• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Making code run on all pages


I am wondering what the best way to run code on each page without having to add it into each controller.

For example if you want to check if a user is logged in on each page, and send them to the login page if they are not logged in. You could add the following to each controller, but I think it would be best to just write this once and run it on each page no matter what.

//send to login

Thanks for clearing this up for me.

Put it in MY_Controller. Then you extend MY_Controller. Do a search on the topic of MY_Controller both here and Google and you will get some good pointers.

So when I create this MY_Controller class I will have to extend that class rather than Controller in each of my controllers?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.