ANSWERED! IT WAS A TYPO OMG. Always check EVERY CHARACTER
I have three controllers, Site, Login and Admin. Site and Login work perfectly. I know I am logging in correctly, because I set the “incorrect username” blah blah error message, which shows up if I have incorrect login details. When I log in successfully however, I get a 500 Internal Server Error:
HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.
Here’s the admin controller:
function __construct()
{
parent::Controller();
$this->isLogged();
}
function isLogged()
{
$isLogged = $this->session->userdata('isLogged');
if (!isset($isLogged) || $isLogged != true)
{
redirect('login/index');
}
}
function index()
{
$data['metaDescription'] = 'Admin area of danaemc.com';
$data['keywords'] = '';
$data['title'] = 'danaemc :: admin :: home';
$data['main_content'] = 'admin_view';
$this->load_view('includes/admin_template', $data);
}
In which where it tries to access index(), the 500 error happens.
If you need more code, let me know in a comment. I hope it is something obvious.
Looks like a problem with your function that checks login. From the code you provide, I see this workflow:
You should do like this instead of using a controller’s method:
Moreover, as a side note, I’d do this check in some method in a library, and have it just return TRUE/FALSE and use that in my controller’s constructor. Like
This just for the sake of business logic and encapsulation, but it’s just an idea and an advice.
If you still want to use the isLogged() of your Controller (but in this way every controller that checks for login needs is own method…) just put an ELSE clause, that redirects to index() if the checking gives positive response.
Edited after comment:
By chance are you calling a favicon in your meta tags?
<link rel="icon" href="http://mysite/assets/favicon.ico" />or whatever url you have? Did you spelled it RIGHT? And don’t have ahref="http://mysite/favicon_ico", which CI things is a controller?