Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Looks like a problem with your function that checks login. From the code you provide, I see this workflow:</p> <ul> <li>User is not logged: he's redirected to login/index and logs in.</li> <li>I suppose then he's redirected to admin controller, right? (when succesfully logged). Ok, now when admin controller is initialized it checks, within the controller itself, if the user is logged.</li> <li>It is, ok, but you don't tell it to go to some other page if the user is logged, so: you go to admin/index, but the constructor "intercepts" your request BEFORE it being routed (since the constructor is called as soon as the class is initialized, before the index() method is ever reached), and it hangs there: index() is called from the URL but the request doesn't go past isLogged(), and this discrepancy can cause you those troubles (I had a similar problem once).</li> </ul> <p>You should do like this instead of using a controller's method:</p> <pre><code>function __construct() { parent::__construct(); //what is parent::Controller() you wrote?? if(!isset($this-&gt;session-&gt;userdata('isLogged')) OR $this-&gt;session-&gt;userdata('isLogged') == FALSE) { redirect('login', 'refresh'); // 'login/index' should be automatically called } } </code></pre> <p>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</p> <pre><code> function __construct() { parent::__construct(); if(FALSE === $this-&gt;myauthlibrary-&gt;is_logged()) { redirect('login','refresh'); } } </code></pre> <p>This just for the sake of business logic and encapsulation, but it's just an idea and an advice.<br /> 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.</p> <p><strong>Edited after comment:</strong></p> <p>By chance are you calling a favicon in your meta tags? <code>&lt;link rel="icon" href="http://mysite/assets/favicon.ico" /&gt;</code> or whatever url you have? Did you spelled it RIGHT? And don't have a <code>href="http://mysite/favicon_ico"</code>, which CI things is a controller?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload