I’m working on an assignment and ran into this weird problem.
So say I enter a username/password and am now logged in. I go to a different website, and want to return back to the webpage I was logged into. This is how I implemented taking care of that situation:
//Controller
public function index()
{
$loggedin = $this->alibrary->is_loggedin();
if ($loggedin === false)
{
$this->load->view('normal_screen');
}
if ($loggedin === true)
{
$this->load->view('homepage');
}
}
But if I have previously logged in and return to the webpage I get a blank screen. But when I’m not logged in it displays the normal screen. I don’t know why I’m getting a blank page, could someone please explain? Thanks
This may be my personal preference but I would rewrite your code as follows:
You’ll notice I use
redirect()when the user is not logged in. My personal preference is to redirect non-logged in users back to the login-in screen if they attempt to access a part of the site that requires authorization.