Welcome Guest, Not a member yet? Register   Sign In
Question about tank_auth
#5

[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('');
                       ...


Messages In This Thread
Question about tank_auth - by El Forum - 12-11-2009, 07:42 AM
Question about tank_auth - by El Forum - 12-11-2009, 08:48 AM
Question about tank_auth - by El Forum - 12-11-2009, 11:45 AM
Question about tank_auth - by El Forum - 12-11-2009, 01:42 PM
Question about tank_auth - by El Forum - 12-14-2009, 03:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB