CodeIgniter Forums
important question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: important question (/showthread.php?tid=33688)



important question - El Forum - 09-05-2010

[eluser]Mostafa Hassan[/eluser]
i do check in construct function

Code:
function __construct(){
        
        parent :: controller();    
// check cookie and admin information        
        $this->load->database();
        $this->db->where('id','1');
        $query_admin = $this->db->get('admin_info');
        foreach ($query_admin -> result_array() as $admin_info){
            
            if (isset($_COOKIE['admin_name']) && isset($_COOKIE['admin_password']) && $_COOKIE['admin_name'] == $admin_info['admin_name'] && $_COOKIE['admin_password'] == $admin_info['admin_password']){
            return true;
            }else{
                    $this->load->view('admin/admin_login');
                    return false;
            }  
        }
// end check
    }

but it still execute other functions
i want to stop executing the other functions

i think return false; not working


important question - El Forum - 09-05-2010

[eluser]slowgary[/eluser]
A class constructor runs upon initializing an object, so if this constructor is in your controller, it'll run every time any of your functions are called, as each function call maps to a page load and each time you visit one of those pages you'll be initializing this controller object.

It's tough to tell what you're trying to do looking at your code, but creating a _remap() frunction in your controller might help your cause: http://ellislab.com/codeigniter/user-guide/general/controllers.html#remapping


important question - El Forum - 09-05-2010

[eluser]Mostafa Hassan[/eluser]
thank you very much slowgary, i solved the problem by separate the login in new controller. so as i can insert cookie by this controller...

Thank you again Smile