Welcome Guest, Not a member yet? Register   Sign In
base_url turns up twice after redirect
#1

[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://local...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
#2

[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
#3

[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.




Theme © iAndrew 2016 - Forum software by © MyBB