[eluser]OES[/eluser]
Infact there is a real simple way to do this.
Here is a example bit of code within a check_access method in MY_Controller. This is within a check_access function and is only fired depending on where uri segment is for the user.
Code:
$id = $this->session->get($area_name . '_id');
$user_areas = $this->session->get('user_areas');
if(empty($id) OR !is_array($user_areas)):
if(strpos($_SERVER['REQUEST_URI'], 'login/') === FALSE):
$this->session->set_userdata('last_url', urlencode($_SERVER['REQUEST_URI']));
redirect("login/$area_name", 'location', 302, true);
endif;
endif;
So once the user has been redirected to the login area you will have there last url in the session.
Once they login just redirect and clear session
Hope this helps.
Lee