Welcome Guest, Not a member yet? Register   Sign In
What's Wrong With My Sessions?
#1

[eluser]ShoeLace1291[/eluser]
I'm having a bit of trouble with a function that I use to create sessions. Everything in the function runs fine until it hits the session set userdata function. I have no idea why this isn't working. This is my function:

Code:
function login($email){
    
        $CI =& get_instance();
        $CI->load->library('session');
        $query = $CI->db->query("
            SELECT id, email, last_active, display_name
            FROM members
            WHERE email = '".$email."'
            LIMIT 1");
        if($query->num_rows() == 0){
            $this->errors = $this->errors + 1;
            $this->error_messages[] = 'The email address was not found in our database.';
            return FALSE;
        } else {
            $member = $query->row_array();
            $session = array( //session data
                        'id' => $member['id'],
                        'last_active' => time(),
                        'display_name' => $member['display_name']
                        );
            if(!$CI->session->set_userdata($session)){
                $this->errors = $this->errors + 1;
                $this->error_messages[] = 'The session class failed to update your session with the appropriate data.';
                return FALSE;
            } else if(!$CI->db->update('members', array('last_active' => time()), array('id' => $member['id']))){
                $this->errors = $this->errors + 1;
                $this->error_messages[] = 'The database failed to update the active record with the given session data.';
                return FALSE;
            } else {
                return TRUE;
            }
            
        }
        
    }

The error that returns is the session line 'The session class failed...'

Any ideas?


Messages In This Thread
What's Wrong With My Sessions? - by El Forum - 04-16-2011, 12:56 AM
What's Wrong With My Sessions? - by El Forum - 04-16-2011, 02:34 AM
What's Wrong With My Sessions? - by El Forum - 04-16-2011, 10:45 PM
What's Wrong With My Sessions? - by El Forum - 04-16-2011, 11:07 PM
What's Wrong With My Sessions? - by El Forum - 04-17-2011, 06:29 AM
What's Wrong With My Sessions? - by El Forum - 04-18-2011, 08:58 AM
What's Wrong With My Sessions? - by El Forum - 04-18-2011, 09:05 AM
What's Wrong With My Sessions? - by El Forum - 04-18-2011, 10:22 AM
What's Wrong With My Sessions? - by El Forum - 04-18-2011, 11:51 AM
What's Wrong With My Sessions? - by El Forum - 04-18-2011, 03:24 PM
What's Wrong With My Sessions? - by El Forum - 04-18-2011, 04:23 PM
What's Wrong With My Sessions? - by El Forum - 04-19-2011, 05:43 PM
What's Wrong With My Sessions? - by El Forum - 04-19-2011, 06:55 PM



Theme © iAndrew 2016 - Forum software by © MyBB