Can i check userlogin in construct ? |
PHP Code: class Admin extends CI_Controller { Up there is my script, i'm trying to check the user login in function __construct. It's working fine, but is it 'in the right way'?
Its ok if you need the client to be logged for all methods inside this controller..
Best VPS Hosting : Digital Ocean
(11-27-2014, 03:46 AM)bobykurniawan Wrote: I think the best way is to use hooks, tutorial in spanish(http://uno-de-piera.com/uso-de-hooks-en-codeigniter), regards.
Hooks v 2.2 http://www.codeigniter.com/user_guide/ge...hooks.html
Hooks v 3.0 http://www.codeigniter.com/userguide3/ge...hooks.html I personally prefer extending the CI Controller instead of using a hook about this but it can be a solution if you decide to use it. Best VPS Hosting : Digital Ocean
CI_Controller -> Base_Admin_Controller (implement here the user check) -> Admin (the called by the router controller)
AJAX requests may also require authentication, for this case I create lighter Base_Admin_Ajax_Controller, with user check again. |
Welcome Guest, Not a member yet? Register Sign In |