Class DatabaseSession
DatabaseSession provides methods to be used with Session.
Property Summary
- 
        $_table protectedCake\ORM\TableReference to the table handling the session data 
- 
        $_tableLocator protectedCake\ORM\Locator\LocatorInterfaceTable locator instance 
- 
        $_timeout protectedintNumber of seconds to mark the session as expired 
Method Summary
- 
          __construct() publicConstructor. Looks at Session configuration information and sets up the session model. 
- 
          close() publicMethod called on close of a database session. 
- 
          destroy() publicMethod called on the destruction of a database session. 
- 
          gc() publicHelper function called on gc for database sessions. 
- 
          getTableLocator() publicGets the table locator. 
- 
          open() publicMethod called on open of a database session. 
- 
          read() publicMethod used to read from a database session. 
- 
          setTableLocator() publicSets the table locator. 
- 
          setTimeout() publicSet the timeout value for sessions. 
- 
          tableLocator() public deprecatedSets the table locator. If no parameters are passed, it will return the currently used locator. 
- 
          write() publicHelper 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): boolMethod called on the destruction of a database session.
Parameters
- 
                string|int$id
- ID that uniquely identifies session in database. 
Returns
boolTrue for successful delete, false otherwise.
gc() ¶ public
gc(int $maxlifetime): boolHelper 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(): Cake\ORM\Locator\LocatorInterfaceGets the table locator.
Returns
Cake\ORM\Locator\LocatorInterfaceopen() ¶ public
open(string $savePath, string $name): boolMethod 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(string|int $id): stringMethod used to read from a database session.
Parameters
- 
                string|int$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): $thisSets the table locator.
Parameters
- 
                Cake\ORM\Locator\LocatorInterface$tableLocator
- LocatorInterface instance. 
Returns
$thissetTimeout() ¶ public
setTimeout(int $timeout): $thisSet the timeout value for sessions.
Primarily used in testing.
Parameters
- 
                int$timeout
- The timeout duration. 
Returns
$thistableLocator() ¶ public
tableLocator(Cake\ORM\Locator\LocatorInterface|null $tableLocator = null): Cake\ORM\Locator\LocatorInterfaceSets 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\LocatorInterfacewrite() ¶ public
write(string|int $id, mixed $data): boolHelper 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
boolTrue for successful write, false otherwise.
