Debug level, cookies, everything

Sep 14, 2007 14:04 GMT  ·  By

In my latest article you learned how to configure the database for CakePHP. Now I will show you how to configure global CakePHP. Global configuration file of CakePHP can be found in cakeappconfigcore.php. From here, you can change debug level, cache checking, session cookie, session timeout, level of security and a lot more other settings.

If you have mod_rewrite enabled and you still want CakePHP urls, delete .htaccess files, but if you don't have mod_rewrite enabled and you want to use CakePHP urls, uncomment the lines: release/.htaccess release/app/.htaccess release/app/webroot/.htaccess

There are 4 levels of debug: 0-production, 1- development, 2- full debug with sql and 3- full debug with sql and dump of the current object. Specifying this setting to a non-zero value will force Cake to print out the results of pr( ) and debug( ) function calls, and stop flash messages from forwarding automatically. In production, the "flash messages" redirect after a time interval. With the other debug levels you get to click the "flash message" to continue. For example, if you want to set the debug level to "full debug with sql", the line should look like this: define('DEBUG', 2);

To change the cookie level of security, change the following line: define('CAKE_SECURITY', 'high'); "High" level means that sessions time out after 10 minutes of inactivity, and session IDs are regenerated on each request, in "medium" sessions time out after 20 minutes of inactivity and in "low" sessions time out after 30 minutes of inactivity. I recommend setting the level to high. To set cookie session timeout, change the value from this line: define('CAKE_SESSION_TIMEOUT', '120');. Session timeout depends on the security level of the cookie. If CAKE_SECURITY define is set high: multiplied by 10, medium: is multiplied by 100, low is: multiplied by 300.

These are the important parameters from the configuration file. Enjoy!