Welcome Guest, Not a member yet? Register   Sign In
Need tips about authentication check (cookies)
#1

(This post was last modified: 11-03-2015, 02:24 AM by Rashid.)

What is the most common and robust auth check pattern in CI?

I personally see two ways:

1) insert check routine into a hook-function ('pre_controller' or 'post_controller_constructor' ?) - one for all controllers - nice
2) write it in __construct() directly, but it forces to duplicate code a lot, for each controller. bad..

I tried 1st way but got this:

PHP Code:
$hook['pre_controller'] = function ()
{
    
$id $this->input->cookie('user_id'); // ERROR: Undefined property: CI_Hooks::$input
    // ...
}; 

It seems that $this->input is absent in function's scope. Maybe I should create standalone class? or entirely different approach?

Please nudge me in a right direction.
Reply


Messages In This Thread
Need tips about authentication check (cookies) - by Rashid - 11-03-2015, 02:21 AM



Theme © iAndrew 2016 - Forum software by © MyBB