CodeIgniter Forums
Sending data array when redirected to control panel - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Sending data array when redirected to control panel (/showthread.php?tid=44582)



Sending data array when redirected to control panel - El Forum - 08-19-2011

[eluser]xtremer360[/eluser]
My question of the day is this. After a successful login I want to to send the user_id in a data array to the control panel when it redirects. I have a lot of code here. 98% of it was code that was written from a authentication library and I'm afraid if I tinker too much with it now I'll end up breaking something else by trying to do one thing. Any help?


Code:
class Auth extends CI_Controller
{
function __construct()
{
    parent::__construct();

    $this->load->helper(array('form', 'url'));
    $this->load->library('form_validation');
    $this->load->library('security');
    $this->load->library('tank_auth');
    $this->lang->load('tank_auth');  

    if ($this->tank_auth->is_logged_in()) {
        redirect('/cpanel/');
    } else {
        redirect('/auth/login/');
    }      
}

function index()
{

}

/**
* Login user on the site
*
* @return void
*/
function login()
{
    if ($this->tank_auth->is_logged_in()) {                                 // logged in
        redirect('/cpanel');

    } elseif ($this->tank_auth->is_logged_in(FALSE)) {                      // logged in, not activated
        redirect('/auth/send_again/');

    } else {
        $data['login_by_username'] = ($this->config->item('login_by_username', 'tank_auth') AND
                $this->config->item('use_username', 'tank_auth'));
        $data['login_by_email'] = $this->config->item('login_by_email', 'tank_auth');

        $this->form_validation->set_rules('login', 'Login', 'trim|required|xss_clean');
        $this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean');
        $this->form_validation->set_rules('remember', 'Remember me', 'integer');

        // Get login for counting attempts to login
        if ($this->config->item('login_count_attempts', 'tank_auth') AND
                ($login = $this->input->post('login'))) {
            $login = $this->security->xss_clean($login);
        } else {
            $login = '';
        }

        $data['errors'] = array();

        if ($this->form_validation->run()) {                                // validation ok
            if ($this->tank_auth->login(
                    $this->form_validation->set_value('login'),
                    $this->form_validation->set_value('password'),
                    $this->form_validation->set_value('remember'),
                    $data['login_by_username'],
                    $data['login_by_email'])) {                             // success
                redirect('/cpanel');

            } else {
                $errors = $this->tank_auth->get_error_message();
                if (isset($errors['banned'])) {                             // banned user
                    $this->_show_message($this->lang->line('auth_message_banned').' '.$errors['banned']);

                } elseif (isset($errors['not_activated'])) {                // not activated user
                    redirect('/auth/send_again/');

                } else {                                                    // fail
                    foreach ($errors as $k => $v)   $data['errors'][$k] = $this->lang->line($v);
                }
            }
        }
        $this->template->set_layout('default')->enable_parser(false);
        $this->template->build('auth/login_form', $data);
    }
}



Sending data array when redirected to control panel - El Forum - 08-19-2011

[eluser]xtremer360[/eluser]
And all of a sudden I'm getting this error when I load my cms inside of FF.

The page isn't redirecting properly

Firefox has detected that the server is redirecting the request for this address in a way that will never complete. This problem can sometimes be caused by disabling or refusing to accept cookies.

I cleared all my cookies and its still giving me that issue as well.