Welcome Guest, Not a member yet? Register   Sign In
Sessions....... :(
#1

[eluser]Unknown[/eluser]
I am taking a stab at CI, and I have hit a bit of a wall. I created a user login function in my user controller, and it works dandy right up until I navigate away from the landing after sucessfully authenticating. My sessions disapear.


I will be using sessions to secure pages, so if your session user id value is not populated then you will be redirected to log in. Anyhow here is what I have.
Code:
function login()
    {


    $this->load->library('validation');
        $this->load->helper('url');
    $this->load->library('session');

    if($_POST['username'])
    {
        $this->load->database();
            $query = $this->db->query("SELECT * FROM users WHERE username = '".$_POST['username']."' and password = '".md5($_POST['password'])."'");
        
        if($query->num_rows() > 0){
            //return true;
            $status = "0";
            
             foreach ($query->result() as $row)
                 {
                 $username = $row->username;
                 $id = $row->id;
            
                }
            
            $sid = array('id' => $id);
            
            
            $this->session->set_userdata($sid);
            $data['goodz'] = $this->session->userdata('id');
            $data['status'] = $status;
            }
                
                else {
                    $status = "1";
                    $data['status'] = $status;
                    $data['goodz'] = $this->session->userdata('id');
                    }    
        }
$this->load->view('login_vals',$data);
    }


Messages In This Thread
Sessions....... :( - by El Forum - 06-22-2007, 07:33 PM
Sessions....... :( - by El Forum - 06-23-2007, 04:38 AM
Sessions....... :( - by El Forum - 07-07-2007, 04:05 AM
Sessions....... :( - by El Forum - 07-07-2007, 09:51 PM



Theme © iAndrew 2016 - Forum software by © MyBB