Protect site using MY_Controller? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Protect site using MY_Controller? (/showthread.php?tid=48080) |
Protect site using MY_Controller? - El Forum - 01-03-2012 [eluser]Sven Delle[/eluser] I'm trying to protect a website using the MY_Controller way. I have a custom config file with: Code: $config['site_protected'] = true; // or false I then have a MY_Controller that looks like this: Code: <?php if(!defined('BASEPATH')) exit('No direct script access allowed'); All pages I want to protect extends the MY_Controller. I then have a login controller, extending CI_Controller (so it does not conflict with the redirect in the MY_Controller). If the login validates I want to change the config setting ($config['site_protected']) to false and send the user to the recorded url. Code: $this->config->set_item('site_protected', false); I then expect the MY_Controller to never redirect the user to the login page again. But this seems not to be the case!? Am I wrong in assuming that the config value will have changed throughout the session? Should I somehow use a session setting, and if, then how? Any help in achieving a simple to maintain solution to the problem are appreciated. But I suspect that the config file gets reloaded on every page visit, and therefore resets back to the default value. Is this the case? |