I’ve made CI authentication controller allowing user to log into the site, and after the login I’m redirecting him to the previously visited URL that I keep using:
$this->session->set_flashdata( 'return_url', current_url() );
Unfortunately that causes a problem. Every time when the user opens more than one tab in the browser that variable is being overwritten and after successful login the user is redirected to the same URL in all the tabs.
So my question is: Is it possible to load a custom controller inside MY_Controller? (MY_Controller is the class that extends CI_Controller)
I tried using (inside the constructor of MY_Controller) but it didn’t worked out:
$CI =& get_instance();
$CI->router->set_class('authentication');
$CI->router->set_method('login');
Edit: I will appreciate any other ideas of solving this problem.
a solution would be not to save the return url in a session var, but pass it around in a get/post parameter (in case of get, properly encoded, base64 ie.). The only addition would have to be a standard return url if no (valid) return url is set
— EDIT
why was i talking about base64 when php has just the function for this; urlencode is your friend! https://www.php.net/urlencode