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
https://forums.phpfreaks.com/topic/290169-web-page-has-a-redirect-loop/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.