Jump to content

Web page has a redirect loop


shvikr

Recommended Posts

Hi,


Am working on hooks wit codeigniter, am getting an error after applying hooks like "This webpage has a redirect loop".


My hooks.php file :


  1. $hook['post_controller_constructor'] = array(
  2. 'class' => 'SessionData',
  3. 'function' => 'initializeData',
  4. 'filename' => 'auth.php',
  5. 'filepath' => 'hooks',
  6. 'params' => array()
  7. );

auth.php file:


  1. <?php
  2. class SessionData{
  3. var $CI;
  4.  
  5. function __construct(){
  6. $this->CI =& get_instance();
  7. if(!isset($this->CI->session))
  8. $this->CI->load->library('session');
  9. }
  10.  
  11. function initializeData() {
  12. if(!$this->CI->session->userdata('admin_id')){
  13. redirect('admin');
  14. }
  15. }
  16. }
  17. ?>

 


Admin controller file:


<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');


 

class Admin extends CI_Controller {

 

 

    public function index()

    {

         $this->load->view('admin/login');

 

    }

 

I need to redirect all calls to admin log in page if the admin is not logged in.

 

Why am getting this error? Please help.


Thanks


Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.