CakeSession Class Info:
- Class Declaration:
- class CakeSession extends Object
- File name:
- cake/libs/session.php
- Summary:
- Session class for Cake. Cake abstracts the handling of sessions. There are several convenient methods to access session information. This class is the implementation of those methods. They are mostly used by the Session Component.
- Class Inheritance
- package
- cake
- subpackage
- cake.cake.libs
Properties:
Show/Hide parent properties
| public | error | Error messages for this session |
| public | id | Current Session id |
| public | lastError | Error number of last occurred error |
| protected | _log | Log object |
| public | path | Path to where the session is active. |
| public | security | 'Security.level' setting, "high", "medium", or "low". |
| public | sessionTime | Time when this session becomes invalid. |
| public | time | Start time for this session. |
| protected | _userAgent | User agent string |
| public | valid | True if the Session is still valid |
| public | watchKeys | Keeps track of keys to watch for writes on |
Method Summary:
Show/Hide parent methods
| public | cakeError( $method, $messages = array ( ) ) |
| public | check( $name ) |
| protected | _checkValid( ) |
| public | __construct( $base = NULL, $start = true ) |
| public | del( $name ) |
| public | destroy( ) |
| public | dispatchMethod( $method, $params = array ( ) ) |
| public | error( ) |
| public | id( $id = NULL ) |
| public | ignore( $var ) |
| public | log( $msg, $type = 2 ) |
| public | Object( ) |
| protected | _persist( $name, $return, $object, $type = NULL ) |
| public | read( $name = NULL ) |
| public | renew( ) |
| public | requestAction( $url, $extra = array ( ) ) |
| protected | _savePersistent( $name, $object ) |
| protected | _set( $properties = array ( ) ) |
| public | start( ) |
| public | started( ) |
| public | _stop( $status = 0 ) |
| public | toString( ) |
| public | valid( ) |
| public | watch( $var ) |
| public | write( $name, $value ) |
cakeError
topUsed to report user friendly errors.
If there is a file app/error.php or app/app_error.php this file will be loaded
error.php is the AppError class it should extend ErrorHandler class.
- Parameters:
-
$method string Method to be called in the error class (AppError or ErrorHandler classes) required (no default) $messages array Message that is to be displayed by the error class optional array ( ) - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 189
- return
- error message
- access
- public
check
topReturns true if given variable is set in session.
- Parameters:
-
$name string Variable name to check for required (no default) - Method defined in class:
- CakeSession
- Method defined in file:
- cake/libs/session.php on line 195
- return
- boolean True if variable is there
- access
- public
_checkValid
topHelper method to create a new session.
- Method defined in class:
- CakeSession
- Method defined in file:
- cake/libs/session.php on line 554
- return
- void
- access
- protected
__construct
topConstructor.
- Parameters:
-
$base string The base path for the Session optional NULL $start boolean Should session be started right now optional true - Method defined in class:
- CakeSession
- Method defined in file:
- cake/libs/session.php on line 127
- access
- public
del
topRemoves a variable from session.
- Parameters:
-
$name string Session variable to remove required (no default) - Method defined in class:
- CakeSession
- Method defined in file:
- cake/libs/session.php on line 228
- return
- boolean Success
- access
- public
destroy
topHelper method to destroy invalid sessions.
- Method defined in class:
- CakeSession
- Method defined in file:
- cake/libs/session.php on line 403
- return
- void
- access
- public
dispatchMethod
topCalls a method on this object with the given parameters. Provides an OO wrapper
for call_user_func_array, and improves performance by using straight method calls
in most cases.
- Parameters:
-
$method string Name of the method to call required (no default) $params array Parameter list to use when calling $method optional array ( ) - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 113
- return
- mixed Returns the result of the method call
- access
- public
error
topReturns last occurred error as a string, if any.
- Method defined in class:
- CakeSession
- Method defined in file:
- cake/libs/session.php on line 280
- return
- mixed Error description as a string, or false.
- access
- public
id
topReturns the Session id
- Parameters:
-
$id optional NULL - Method defined in class:
- CakeSession
- Method defined in file:
- cake/libs/session.php on line 210
- return
- string Session id
- access
- public
ignore
topTells Session to stop watching a given key path
- Parameters:
-
$var mixed The variable path to watch required (no default) - Method defined in class:
- CakeSession
- Method defined in file:
- cake/libs/session.php on line 364
- return
- void
- access
- public
log
topAPI for logging events.
- Parameters:
-
$msg string Log message required (no default) $type integer Error type constant. Defined in app/config/core.php. optional 2 - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 150
- return
- boolean Success of log write
- access
- public
Object
topA hack to support __construct() on PHP 4
Hint: descendant classes have no PHP4 class_name() constructors,
so this constructor gets called first and calls the top-layer __construct()
which (if present) should call parent::__construct()
- Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 53
- return
- Object
_persist
topChecks for a persistent class file, if found file is opened and true returned
If file is not found a file is created and false returned
If used in other locations of the model you should choose a unique name for the persistent file
There are many uses for this method, see manual for examples
- Parameters:
-
$name string name of the class to persist required (no default) $return required (no default) $object string the object to persist required (no default) $type optional NULL - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 219
- return
- boolean Success
- access
- protected
- todo
- add examples to manual
read
topReturns given session variable, or all of them, if no parameters given.
- Parameters:
-
$name mixed The name of the session variable (or a path as sent to Set.extract) optional NULL - Method defined in class:
- CakeSession
- Method defined in file:
- cake/libs/session.php on line 313
- return
- mixed The value of the session variable
- access
- public
renew
topRestarts this session.
- Method defined in class:
- CakeSession
- Method defined in file:
- cake/libs/session.php on line 624
- access
- public
requestAction
topCalls a controller's method from any location.
- Parameters:
-
$url mixed String or array-based url. required (no default) $extra array if array includes the key "return" it sets the AutoRender to true. optional array ( ) - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 86
- return
- mixed Boolean true or false on success/failure, or contents of rendered action if 'return' is set in $extra.
- access
- public
_savePersistent
topYou should choose a unique name for the persistent file
There are many uses for this method, see manual for examples
- Parameters:
-
$name string name used for object to cache required (no default) $object object the object to persist required (no default) - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 247
- return
- boolean true on save, throws error if file can not be created
- access
- protected
_set
topAllows setting of multiple properties of the object in a single line of code.
- Parameters:
-
$properties array An associative array containing properties and corresponding values. optional array ( ) - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 169
- return
- void
- access
- protected
start
topStarts the Session.
- Method defined in class:
- CakeSession
- Method defined in file:
- cake/libs/session.php on line 169
- return
- boolean True if variable is there
- access
- public
started
topDetermine if Session has been started.
- Method defined in class:
- CakeSession
- Method defined in file:
- cake/libs/session.php on line 182
- access
- public
- return
- boolean True if session has been started.
_stop
topStop execution of the current script
- Parameters:
-
$status optional 0 - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 139
- return
- void
- access
- public
toString
topObject-to-string conversion.
Each class can override this method as necessary.
- Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 73
- return
- string The name of this class
- access
- public
valid
topReturns true if session is valid.
- Method defined in class:
- CakeSession
- Method defined in file:
- cake/libs/session.php on line 293
- return
- boolean Success
- access
- public
watch
topTells Session to write a notification when a certain session path or subpath is written to
- Parameters:
-
$var mixed The variable path to watch required (no default) - Method defined in class:
- CakeSession
- Method defined in file:
- cake/libs/session.php on line 348
- return
- void
- access
- public
write
topWrites value to given session variable name.
- Parameters:
-
$name mixed Name of variable required (no default) $value string Value to write required (no default) - Method defined in class:
- CakeSession
- Method defined in file:
- cake/libs/session.php on line 385
- return
- boolean True if the write was successful, false if the write failed
- access
- public