CodeIgniter Forums
Restricting access to specific functions in controllers - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Restricting access to specific functions in controllers (/thread-24431.html)



Restricting access to specific functions in controllers - El Forum - 11-10-2009

[eluser]sjmiller85[/eluser]
A while back on a project since gone and over with I recall being able to restrict access to specific functions within my controller. For instance, I would create callback functions for form validation. Obviously, these functions serve no other purpose than to be called during the form validation, so having users type in the url to the function (ie base_url/controller/callback_function) is not needed and if at all possible, I'd like to prevent this.

I seem to remember being able to add an access modifier to the function to prevent direct access to those functions, but I cannot seem to replicate this. Can someone please enlighten me on the best practices of preventing direct browser access to specific functions?


Restricting access to specific functions in controllers - El Forum - 11-10-2009

[eluser]vitoco[/eluser]
i think the modifier is "_", like this :

function function_with_direct_access()
function _function_without_direct_access()


Restricting access to specific functions in controllers - El Forum - 11-10-2009

[eluser]sjmiller85[/eluser]
That seems to have done the trick! Thanks much for your assistance!


Restricting access to specific functions in controllers - El Forum - 11-10-2009

[eluser]rogierb[/eluser]
add 'private' to your method or '_' if in php4


Restricting access to specific functions in controllers - El Forum - 11-10-2009

[eluser]sjmiller85[/eluser]
That's the problem though, I would add private to my methods, and I would receive errors... Hence the confusion, as that is what I thought I did before...