Restrict access to MY_Controller functions - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Restrict access to MY_Controller functions (/showthread.php?tid=33027) |
Restrict access to MY_Controller functions - El Forum - 08-13-2010 [eluser]dynZack[/eluser] How do you restrict access in certain functions defined within MY_Controller? For example: Code: class MX_Controller extends Controller Going to http://www.example.com/set_cookies outputs a blank page and not a 403 error. How to make sure that access is forbidden, output a message and redirect to home page? Restrict access to MY_Controller functions - El Forum - 08-13-2010 [eluser]mddd[/eluser] If you want a controller method to never be available to the public (that is: you can only call it from within your own code) you can start the name with a _. CI will not make the method available to be called from the URI. Note: this has nothing to do with being in a controller or in MY_Controller. Like this: Code: function _set_cookies() Restrict access to MY_Controller functions - El Forum - 08-13-2010 [eluser]dynZack[/eluser] Thanks for the quick answer! |