Class DatabaseSession
DatabaseSession provides methods to be used with Session.
Properties summary
- $_table protected
\Cake\ORM\TableReference to the table handling the session data
- $_tableLocator protected
\Cake\ORM\Locator\LocatorInterface|nullTable locator instance
- $_timeout protected
intNumber of seconds to mark the session as expired
Method Summary
- __construct() public
Constructor. Looks at Session configuration information and sets up the session model.
Method Detail
__construct() public
__construct(array $config)
Constructor. Looks at Session configuration information and sets up the session model.
Parameters
-
array$config optional The configuration for this engine. It requires the 'model' key to be present corresponding to the Table to use for managing the sessions.
close() public
close()
Method called on close of a database session.
Returns
boolSuccess
destroy() public
destroy(mixed $id)
Method called on the destruction of a database session.
Parameters
-
string$id ID that uniquely identifies session in database.
Returns
boolTrue for successful delete, false otherwise.
gc() public
gc(mixed $maxlifetime)
Helper function called on gc for database sessions.
Parameters
-
int$maxlifetime Sessions that have not updated for the last maxlifetime seconds will be removed.
Returns
boolTrue on success, false on failure.
getTableLocator() public
getTableLocator()
Gets the table locator.
Returns
\Cake\ORM\Locator\LocatorInterfaceopen() public
open(mixed $savePath, mixed $name)
Method called on open of a database session.
Parameters
-
string$savePath The path where to store/retrieve the session.
-
string$name The session name.
Returns
boolSuccess
read() public
read(mixed $id)
Method used to read from a database session.
Parameters
-
string$id ID that uniquely identifies session in database.
Returns
stringSession data or empty string if it does not exist.
setTableLocator() public
setTableLocator(\Cake\ORM\Locator\LocatorInterface $tableLocator)
Sets the table locator.
Parameters
-
\Cake\ORM\Locator\LocatorInterface$tableLocator LocatorInterface instance.
Returns
$thissetTimeout() public
setTimeout(int $timeout)
Set the timeout value for sessions.
Primarily used in testing.
Parameters
-
int$timeout The timeout duration.
Returns
$thiswrite() public
write(mixed $id, mixed $data)
Helper function called on write for database sessions.
Parameters
-
string$id ID that uniquely identifies session in database.
-
string$data The data to be saved.
Returns
boolTrue for successful write, false otherwise.
Property Detail
$_table protected
Reference to the table handling the session data
Type
\Cake\ORM\Table$_tableLocator protected
Table locator instance
Type
\Cake\ORM\Locator\LocatorInterface|null$_timeout protected
Number of seconds to mark the session as expired
Type
int
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.1/class-Cake.Http.Session.DatabaseSession.html