Welcome Guest, Not a member yet? Register   Sign In
Custom logout function not working
#1

[eluser]RyanH[/eluser]
I've been trying to figure out why my custom logout function isn't working and I can't seem to figure it out. I realize that my code is probably not the best way to go about doing things, so I'm open to suggestions. I'm still learning my way around CodeIgniter. My code is below so if anybody has any advice, I'd appreciate it. Thanks.

Code:
// Run the validation and if it's not successful return them to the login page
        // If the validation is successful, process the login
        
        if($this->validation->run() == FALSE)
        {
            $this->load->view('login_view');
        } else {            
            $data = array(
                'email' => $this->validation->email,
                'password' => $this->validation->password
                );
                
            $this->db->where(array('email' => $this->validation->email, 'password' => $this->validation->password));
            $query = $this->db->get('users');
            
            if($query->num_rows() > 0)
            {
            /*    $newData = array(
                    'email' => $this->validation->email,
                    'logged_in' => 1
                    );

                $this->session->set_userdata('email', $this->validation->email); */
                
                $this->load->view('login_complete');
            } else {
                $this->load->view('login_view');
            }
        }
    }
    
    function logout()
    {
        $logout = $this->session->sess_destroy();
        if($logout)
        {
            $this->load->view('home_view');
        } else {
            echo 'Error logging out';
        }
    }

This is the code on the temporary page that loads if you're login was successful (located at the very top of the page):
Code:
if(!$this->session->userdata('session_id'))
        {
            redirect('login', 'location');
         } else {
                echo 'Welcome ' . anchor('login/logout', 'Logout');
        }


Messages In This Thread
Custom logout function not working - by El Forum - 03-15-2008, 12:26 AM
Custom logout function not working - by El Forum - 03-15-2008, 02:33 AM
Custom logout function not working - by El Forum - 03-15-2008, 12:16 PM
Custom logout function not working - by El Forum - 03-15-2008, 02:30 PM
Custom logout function not working - by El Forum - 03-15-2008, 10:42 PM
Custom logout function not working - by El Forum - 03-16-2008, 01:13 AM
Custom logout function not working - by El Forum - 03-16-2008, 10:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB