Welcome Guest, Not a member yet? Register   Sign In
Return To
#1

[eluser]georgerobbo[/eluser]
I am developing an application where to comment you must login. So when you click login you are redirected to login controller. However once you have logged in you have lost where you previously were.

How do I store the page they we're previously on before going to the login controller, so I can give them the option to go back to that page.
#2

[eluser]jedd[/eluser]
In MY_Controller I have this function:
Code:
function  _ensure_authenticated_user ( $page_message = "this")  {
        if (! $this->session->userdata('handle'))  {
            $this->session->set_flashdata('user_needs_to_login', $page_message);
            $this->session->set_flashdata('return_to_page', uri_string());
            redirect('/people/login');
            }
        }

In my normal controllers, I call $this->_ensure_authenticated_user('foo') within the constructor, with foo being a string I construct from the class and sometimes the method name.

I'll probably re-write this to not use flashdata - the keep_flashdata() shuffle is too bothersome given the non-existent gain from using flash rather than normal session data.
#3

[eluser]überfuzz[/eluser]
There might be a niftier way, but you could do it something like this.
Code:
//users hitting submit without being logged
//store the current url in a session.
redirect('login');

//do login
$url = $this->session->userdata('url');
redirect($url);
#4

[eluser]georgerobbo[/eluser]
Oh awesome, thanks very much!




Theme © iAndrew 2016 - Forum software by © MyBB