[eluser]oualid[/eluser]
I did the following:
In /controller/welcome2.php I added the following lines:
Code:
class Welcome2 extends Controller
{
function __construct()
{
parent::__construct();
$this->load->helper('url');
$this->load->library('tank_auth');
$this->load->library('session'); //New line added
}
function index()
{
if (!$this->tank_auth->is_logged_in()) {
$this->session->set_userdata('redirect_url', $this->uri->uri_string()); //New line added
redirect('/auth/login/');
$this->session->unset_userdata('redirect_url'); //New line added
} else {
$data['user_id'] = $this->tank_auth->get_user_id();
$data['username'] = $this->tank_auth->get_username();
$this->load->view('welcome2', $data);
}
}
}
And in /controller/auth.php I added the following lines in function login():
Code:
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_url = $this->session->userdata('redirect_url'); //New line added
redirect($redirect_url); //New line added
//redirect('');
...