Securing controller's |
[eluser]Achmed1[/eluser]
Hi, Im new to codeigniter i want to know how i can secure my controller for example i got a controller that shows data from the database like localhost/mywebsite/controller1 but i dont want that somebody directly can access this controller how can i fix it?
[eluser]CroNiX[/eluser]
I suppose it depends on your goal and I assume you want at least one person to be able to access the url. If so, you'd need some sort of authentication system and only allow authenticated users or users with sufficient permissions to view the url. If it's a helper type of method that you never want to be able to access via the url, but want other methods within the class to still be able to access, you just prefix the method name with an underscore. Code: class Something extends CI_Controller { Going to http://yoursite.com/something/_get_users will result in an error because it's a "private" method. Going to http://yoursite.com/something/get_users will work. |
Welcome Guest, Not a member yet? Register Sign In |