[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.