CodeIgniter Forums
base_url turns up twice after redirect - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: base_url turns up twice after redirect (/showthread.php?tid=21401)



base_url turns up twice after redirect - El Forum - 08-09-2009

[eluser]cybercy[/eluser]
hi.

i use DX_Auth for login in my application, and after logging in, i want to take the user back to the page where he came from. Please note that I use a lightbox login window.

It works fine, but after the redirect, the URL is incorrect, it shows my base_url and then the full path of the referrer. Like this:

http://localhost/production/http://localhost/production/main/location/9

The controller:

Code:
function login()
    {
        if ( ! $this->dx_auth->is_logged_in())
        {
            $val = $this->form_validation;
            
            // Set form validation rules
            $val->set_rules('username', 'Username', 'trim|required|xss_clean');
            $val->set_rules('password', 'Password', 'trim|required|xss_clean');
            $val->set_rules('remember', 'Remember me', 'integer');
            $hello = $this->agent->referrer();

            // Set captcha rules if login attempts exceed max attempts in config
            if ($this->dx_auth->is_max_login_attempts_exceeded())
            {
                $val->set_rules('captcha', 'Confirmation Code', 'trim|required|xss_clean|callback_captcha_check');
            }
                
            if ($val->run() AND $this->dx_auth->login($val->set_value('username'), $val->set_value('password'), $val->set_value('remember')))
            {
                // Redirect to homepage
                redirect($hello);
            }
            else
            { .......blablabla

What do i do wrong? Please help!
Thanks


base_url turns up twice after redirect - El Forum - 08-09-2009

[eluser]designfellow[/eluser]
Hi,
you can set a session variable before redirecting to login.
$this->session->set_userdata('referring_page',uri_string());
after successfully logged in u can simply redirect like this.
redirect($this->session->userdata('referring_page')
);

Happy Coding,
DesignFellow


base_url turns up twice after redirect - El Forum - 08-09-2009

[eluser]cybercy[/eluser]
Thanks!!!!! Smile
You cannot imagine how many hours I was playing around with this, and with your hint, it works.

thanks again.