Note that there are some explanatory texts on larger screens.

plurals
  1. POUser authentication using CodeIgniter
    primarykey
    data
    text
    <p>I have a problem creating authentication part for my application.</p> <p>Below is the simplified version of my controllers.</p> <p>The idea is that the MY_controller checks if session with user data exists. If it doesn’t, then redirects to the index page where you have to log in.</p> <p>MY_controller.php</p> <pre><code>class MY_Controller extends Controller { function __construct() { parent::__construct(); $this-&gt;load-&gt;helper('url'); $this-&gt;load-&gt;library('session'); if($this-&gt;session-&gt;userdata('user') == FALSE) { redirect('index'); } else { redirect('search'); } } } </code></pre> <p>order.php - main controller</p> <pre><code>class Orders extends MY_Controller { function __construct() { parent::__construct(); $this-&gt;load-&gt;helper('url'); $this-&gt;load-&gt;library('session'); } function index() { // Here would be the code that validates information input by user. // If validation is successful, it creates user session. $this-&gt;load-&gt;view('header.html', $data); // load header $this-&gt;load-&gt;view('index_view', $data); // load body $this-&gt;load-&gt;view('footer.html', $data); // load footer } function search() { //different page } </code></pre> <p>what is happening is that the browser is telling me that “The page isn’t redirecting properly. Firefox has detected that the server is redirecting the request for this address in a way that will never complete.”</p> <p>It seems like the redirect() is being looped. I looked at a few other examples of user auth and they were build using similar technique.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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