php - Redirect loop in Codeigniter with single redirect from base controller -


i have base controller:

class tcms_controller extends  ci_controller{     public function __construct(){         parent::__construct();         if( ! $this->session->userdata('logged_in')){             redirect('admin/authenticate/login');         }         //loop settings in "globals" table         foreach($this->settings_model->get_global_settings() $result){             $this->global_data[$result->key] = $result->value;         }     } } 

so there have basic redirect:

redirect('admin/authenticate/login'); if user not logged in.

also have settings remove index.php urls:

.htaccess:

options +followsymlinks options -indexes directoryindex index.php rewriteengine on rewritecond $1 !^(index\.php|resources|images|css|js|robots\.txt|favicon\.ico) rewritecond %{request_filename} !-f rewritecond ${request_filename} !-d rewriterule ^(.*)$ index.php?/$1 [l] 

and next config settings:

$config['base_url'] = 'http://something.herokuapp.com/'; $config['index_page'] = ''; 

and when i'm trying access admin section has next address:

http://something.herokuapp.com/admin/controller/method 

and if i'm not logged in, supposed redirected login page:

http://something.herokuapp.com/admin/authenticate/login 

but instead redirect loop

err_too_many_redirects

how fix it?

the page: http://tcms.herokuapp.com/

the admin section: http://tcms.herokuapp.com/admin/authenticate/login http://tcms.herokuapp.com/admin/dashobard

i sure admin(may authenticate if admin folder name) controller extends tcms_controller. when redirects admin controller executes tcms_controller's construct function again , again redirect admin controller cause infinite loop.

to sovle need make login controller not extends tcms_controller extends ci_controller.and redirect controller if user not loged-in.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -