[eluser]KeyStroke[/eluser]
Hi,
I have some protected pages on my site that only members can access. I want to code my application so that, when a non-member tries to access any of those pages, he will be sent to a login page. Once he logins successfully, he will be sent back to the page he was trying to access.
I've tried the following:
Code:
function login()
{
$view_data = array();
$this->session->set_userdata(array('last_visited_page' => $_SERVER['HTTP_REFERER']));
/*
Authentication and some code goes here
*/
// if login is successful, redirect to last page
redirect($this->session->userdata('last_visited_page'));
The problem with this code is if the login wasn't successful, the "last_visited_page' would be the login page itself, which I don't want. I can let every restricted page (function) tell set the session data itself, but that would be a lot of code.
Any ideas?