TUTORIAL : simple side wide login |
[eluser]xwero[/eluser]
I'm back with a tutorial on how to use hooks in a creative manner. This time i'm going to demonstrate a simple authentication with side wide login form. The common way to do this is to extend the controller and place the intercepting code there but with hooks you don't have to extend the controllers. Code: function login_form() I'm not putting the functions into a class because you will never write the functions yourself in controller code. Once namespaces are available i would add them to a namespace to minimize the risk of having a function with the same name. The config/hooks.php looks like this Code: $hook['post_controller_constructor'][] = array( The placing of the hook functions is important. The first two hooks can be switched but the third has to be last. And that is it. Now you have a reusable, basic authentication solution.
[eluser]joneslee[/eluser]
If possible, can you post up your auth_model and users_model code?
[eluser]GSV Sleeper Service[/eluser]
load-vars() is new to me, must have missed that when reading the docs. Quote:I’m not putting the functions into a class because you will never write the functions yourself in controller code.I don't understand this line, why wouldn't I? [edit] - about this load->vars() thing. shouldn't your code look like this, or am I completely misunderstanding how load->vars() works? Code: function login_form() |
Welcome Guest, Not a member yet? Register Sign In |