views:

260

answers:

2

I want to understand how Configure::write('Config.language','fre'), do I have to call this function in beforFilter() methode ? when i call it does it save the the configuration in session or it does not save at all ?

+4  A: 

Configure::write() is really just for setting CakePHP configuration directives. You don't want to use it to write to the session (in fact, it just flat out doesn't do that). Chances are good that you're barking up the wrong tree if you're trying to use it. If it's saving state between requests that you want, check out the Session component at http://book.cakephp.org/view/173/Sessions

Travis Leleu
A: 

Configure::write() is for writing application wide constants. So if you want to set a limit on products or something like that you could set that globally using Configure::write().

Then you can use Configure::read() to read that value out again.

I mainly use it to store application settings :)

DavidYell
Here you are talking about storing (saving) but it does not behave like that (i have to write the config at every request)
Ayoub
Config::write() should be used in your app/config/core.php, if you are saving into the session in your controller $this->Session->write()
DavidYell