Свойство | Тип | Описание | |
---|---|---|---|
$db | the DB connection object or the application component ID of the DB connection. After the DbSession object is created, if you want to change this property, you should only assign it with a DB connection object. Starting from version 2.0.2, this can also be a configuration array for creating the object. | ||
$sessionTable | the name of the DB table that stores the session data. The table should be pre-created as follows: sql CREATE TABLE session ( id CHAR(40) NOT NULL PRIMARY KEY, expire INTEGER, data BLOB ) where 'BLOB' refers to the BLOB-type of your preferred DBMS. Below are the BLOB type that can be used for some popular DBMS: - MySQL: LONGBLOB - PostgreSQL: BYTEA - MSSQL: BLOB When using DbSession in a production server, we recommend you create a DB index for the 'expire' column in the session table to improve the performance. Note that according to the php.ini setting of session.hash_function, you may need to adjust the length of the id column. For example, if session.hash_function=sha256, you should use length 64 instead of 40. |
Метод | Описание | |
---|---|---|
destroySession ( string $id ) : boolean | Session destroy handler. | |
gcSession ( integer $maxLifetime ) : boolean | Session GC (garbage collection) handler. | |
init ( ) | Initializes the DbSession component. | |
readSession ( string $id ) : string | Session read handler. | |
regenerateID ( boolean $deleteOldSession = false ) | Updates the current session ID with a newly generated one . | |
writeSession ( string $id, string $data ) : boolean | Session write handler. |
public destroySession ( string $id ) : boolean | ||
$id | string | session ID |
Результат | boolean | whether session is destroyed successfully |
public init ( ) |
public readSession ( string $id ) : string | ||
$id | string | session ID |
Результат | string | the session data |
public regenerateID ( boolean $deleteOldSession = false ) | ||
$deleteOldSession | boolean | Whether to delete the old associated session file or not. |
public $db |
public $sessionTable |