how to: conditonal config |
Hi,
I want to be able to change the cache dir depending whether or not a suer is logged in. I'm trying to do this from within the head.php view and have tried a bunch of methods including: $CI =& get_instance(); if ($cust > 0) { $config['cache_path'] = '/location/to/my/install/application/cache2'; } What is the correct syntax please? Thanks a lot.
i think the best way to achieve what you want is a hook - below an example
in your application/config/hooks.php PHP Code: $hook['pre_controller'][] = array( in your application/hooks/ folder put a file named AppConfigCustomization.php PHP Code: class AppConfigCustomization something like this is clean and should work
Bugger. didn't work. Tried a few variations on this, and it just wont overwrite the default cache path.
As long as you don't reload the config file after you do this, the following should work:
PHP Code: $this->config->set_item('cache_path', '/location/to/my/install/application/cache2'); http://www.codeigniter.com/user_guide/li...onfig-item
*sigh* this is hurting my head.
I'm able to set cache path, but the problem now is that the session seems to be cached itself! As soon as user logs in and caches the page to the assigned dir, even if I log out again, I'm still getting the logged in cache files being returned. eg: PHP Code: $cust_id = $this->session->userdata('cust_id'); I guess the solution lies in environments, but how to assign an environment based on session data? It all seems to be like a chicken and egg situation. |
Welcome Guest, Not a member yet? Register Sign In |