\Cake\Http\SessionDatabaseSession

DatabaseSession provides methods to be used with Session.

Summary

Methods
Properties
Constants
tableLocator()
setTableLocator()
getTableLocator()
__construct()
setTimeout()
open()
close()
read()
write()
destroy()
gc()
No public properties found
No constants found
No protected methods found
$_tableLocator
$_table
$_timeout
N/A
No private methods found
No private properties found
N/A

Properties

$_table

$_table : \Cake\ORM\Table

Reference to the table handling the session data

Type

\Cake\ORM\Table

$_timeout

$_timeout : integer

Number of seconds to mark the session as expired

Type

integer

Methods

tableLocator()

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

LocatorInterface instance.

Returns

\Cake\ORM\Locator\LocatorInterface

setTableLocator()

setTableLocator(\Cake\ORM\Locator\LocatorInterface  $tableLocator) : $this

Sets the table locator.

Parameters

\Cake\ORM\Locator\LocatorInterface $tableLocator

LocatorInterface instance.

Returns

$this

__construct()

__construct(array  $config = array()) 

Constructor. Looks at Session configuration information and sets up the session model.

Parameters

array $config

The configuration for this engine. It requires the 'model' key to be present corresponding to the Table to use for managing the sessions.

setTimeout()

setTimeout(integer  $timeout) : $this

Set the timeout value for sessions.

Primarily used in testing.

Parameters

integer $timeout

The timeout duration.

Returns

$this

open()

open(string  $savePath, string  $name) : boolean

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

boolean —

Success

close()

close() : boolean

Method called on close of a database session.

Returns

boolean —

Success

read()

read(string|integer  $id) : string

Method used to read from a database session.

Parameters

string|integer $id

ID that uniquely identifies session in database.

Returns

string —

Session data or empty string if it does not exist.

write()

write(string|integer  $id, mixed  $data) : boolean

Helper function called on write for database sessions.

Parameters

string|integer $id

ID that uniquely identifies session in database.

mixed $data

The data to be saved.

Returns

boolean —

True for successful write, false otherwise.

destroy()

destroy(string|integer  $id) : boolean

Method called on the destruction of a database session.

Parameters

string|integer $id

ID that uniquely identifies session in database.

Returns

boolean —

True for successful delete, false otherwise.

gc()

gc(integer  $maxlifetime) : boolean

Helper function called on gc for database sessions.

Parameters

integer $maxlifetime

Sessions that have not updated for the last maxlifetime seconds will be removed.

Returns

boolean —

True on success, false on failure.