Hello Whether I'm using a post_controller hook to validate the user or not that it is logged or not When verification fails, I redirect the user to admin login .. .. This problem occurs when this default controller post_computer hook is called again and this way infinite loop starts with repeated redirection is. I want to call the post_controller hook for each controller except the login controller ... This is also the way I do not need to load the session library repeatedly because, if the user is logged in then this session The controller also loads with the post controller via automatic load into the config file ... here is my code
// hook $ hook ['post_controller'] = array (' Class' = & gt; 'is_login', 'function' = & Gt; 'index', 'filename' = & gt; 'is_login.php', 'filepath' = & gt; hook '); // Is_Login hook class is_login {function __construct () {$ this- & gt; CI = & amp; get Instance(); If (! Isset ($ this-> CI-> Session)) / See whether the session has been loaded or not $ this-> CI- & gt; Load-> Library ('session'); // If it is not loaded, load it here) Public Function Index () {$ login_id = $ this- & gt; CI- & gt; Session-> User data ('login_id'); $ Login_flag = $ this- & gt; CI- & gt; Session-> User data ('log in_in'); If ($ login_flag! = TRUE || $ login_id == "") {redirect (site_url) '/ Welcome_login', 'refresh'); It seems that it is not a good place to use the Codeigniter hook. It is better that if you expand the controller class in your application and in the constructor, you can check that the user is logged in and the login controller is redirected. Does. But there is no need to expand the login controller with your controller, instead, increase it from the CI single controller.
Comments
Post a Comment