Jump to content

No response returned


Xtremer360

Recommended Posts

When I submit the login form its not returning anything and it was working until I added in the $remember part so I'm wondering why its still not returning TRUE.

 

/**
 * Login user on the site. Return TRUE if login is successful
 * (user exists and activated, password is correct), otherwise FALSE.
 *
 * @param	string
 * @param	string
 * @param	int
 * @return	bool
 */
    function login($username, $password, $remember)
    {   
        $this->ci->load->model('kow_auth/users');
        $user_data = $this->ci->users->get_user_by_username($username);
        
        if ($user_data)
        {
            $regenFromPostPW = $this->ci->genfunc->reGenPassHash($password, $user_data->password2);
            if ($regenFromPostPW == $user_data->password)
            {
                $this->ci->session->set_userdata(array(
                                'xtr'       => 'yes',
							'user_id'	=> $user_data->user_id,
							'username'	=> $user_data->username,
							'status'	=> $user_data->users_statuses_id,
                                'role'  	=> $user_data->users_roles_id
					));
                if ($remember == 1)
                {
                    $timeTOexpire = time()+(60*60*24*31*2);
                    $this->input->set_cookie('xtrcook', '1', $timeTOexpire);
                }
                else
                {
                    $cookie = trim(get_cookie('xtrcook'));
                    if ($cookie || is_numeric($cookie))
                    {
                        delete_cookie('xtrcook');
                    }
                }
                $this->clear_login_attempts($user_data->user_id);
                $this->ci->users->insert_session($this->ci->session->userdata('session_id'), $this->ci->session->userdata('user_id'), $this->ci->genfunc->getRealIpAddr(), $this->ci->genfunc->getUserOS());
                return TRUE;
            }
            else
            {
                $this->increase_login_attempt($user_data->user_id);
            }
        }
        else
        {
            return NULL;
        }    
    }

Link to comment
https://forums.phpfreaks.com/topic/258012-no-response-returned/
Share on other sites

Your function doesn't return TRUE or FALSE in all cases. In particular:

 

<?php
if ($regenFromPostPW == $user_data->password)
{
    // Your code here returns TRUE
}
else
{
    $this->increase_login_attempt($user_data->user_id);

    // No return value here so you're probably ending up with NULL.
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.