Class DatabaseSession
DatabaseSession provides methods to be used with Session.
Property Summary
-
$_table protected
Cake\ORM\Table
Reference to the table handling the session data
-
$_tableLocator protected
Cake\ORM\Locator\LocatorInterface
Table locator instance
-
$_timeout protected
int
Number of seconds to mark the session as expired
Method Summary
-
__construct() public
Constructor. Looks at Session configuration information and sets up the session model.
-
close() public
Method called on close of a database session.
-
destroy() public
Method called on the destruction of a database session.
-
gc() public
Helper function called on gc for database sessions.
-
getTableLocator() public
Gets the table locator.
-
open() public
Method called on open of a database session.
-
read() public
Method used to read from a database session.
-
setTableLocator() public
Sets the table locator.
-
setTimeout() public
Set the timeout value for sessions.
-
tableLocator() public deprecated
Sets the table locator. If no parameters are passed, it will return the currently used locator.
-
write() public
Helper function called on write for database sessions.
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.
destroy() ¶ public
destroy(string|int $id): bool
Method called on the destruction of a database session.
Parameters
-
string|int
$id ID that uniquely identifies session in database.
Returns
bool
gc() ¶ public
gc(int $maxlifetime): bool
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
bool
getTableLocator() ¶ public
getTableLocator(): Cake\ORM\Locator\LocatorInterface
Gets the table locator.
Returns
Cake\ORM\Locator\LocatorInterface
open() ¶ public
open(string $savePath, string $name): bool
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
bool
read() ¶ public
read(string|int $id): string
Method used to read from a database session.
Parameters
-
string|int
$id ID that uniquely identifies session in database.
Returns
string
setTableLocator() ¶ public
setTableLocator(Cake\ORM\Locator\LocatorInterface $tableLocator): $this
Sets the table locator.
Parameters
-
Cake\ORM\Locator\LocatorInterface
$tableLocator LocatorInterface instance.
Returns
$this
setTimeout() ¶ public
setTimeout(int $timeout): $this
Set the timeout value for sessions.
Primarily used in testing.
Parameters
-
int
$timeout The timeout duration.
Returns
$this
tableLocator() ¶ public
tableLocator(Cake\ORM\Locator\LocatorInterface|null $tableLocator = null): Cake\ORM\Locator\LocatorInterface
Sets the table locator. If no parameters are passed, it will return the currently used locator.
Parameters
-
Cake\ORM\Locator\LocatorInterface|null
$tableLocator optional LocatorInterface instance.
Returns
Cake\ORM\Locator\LocatorInterface
write() ¶ public
write(string|int $id, mixed $data): bool
Helper function called on write for database sessions.
Parameters
-
string|int
$id ID that uniquely identifies session in database.
-
mixed
$data The data to be saved.
Returns
bool