cakephp-manual-28jan07

Page 84

http://manual.cakephp.org/printing/chapter/session

CakePHP: The Manual The Cake Session Component Section 1

Cake Session Storage Options Cake comes preset to save session data in three ways: as temporary files inside of your Cake installation, using the default PHP mechanism, or serialized in a database. By default, Cake uses PHP's default settings. To override this in order to use temp files or a database, edit your core configuration file at /app/config/core.php. Change the CAKE_SESSION_SAVE constant to 'cake', 'php', or 'database', depending on your application's needs.

core.php Session Configuration /** * CakePHP includes 3 types of session saves * database or file. Set this to your preferred method. * If you want to use your own save handler place it in * app/config/name.php DO NOT USE file or database as the name. * and use just the name portion below. * * Setting this to cake will save files to /cakedistro/tmp directory * Setting it to php will use the php default save path * Setting it to database will use the database * * */ define('CAKE_SESSION_SAVE', 'php');

In order to use the database session storage, you'll need to create a table in your database. The schema for that table can be found in /app/config/sql/sessions.sql. Section 2

Using the Cake Session Component The Cake session component is used to interact with session information. It includes basic session reading and writing, but also contains features for using sessions for error and reciept messages (i.e. "Your data has been saved"). The Session Component is available in all Cake controllers by default. Here are some of the functions you'll use most: check string $name Checks to see if the current key specified by $name has been set in the session. del string $name delete string $name

1 of 2

1/28/2007 1:19 PM


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.