Class CDbHttpSession
CDbHttpSession extends CHttpSession
by using database as session data
storage.
CDbHttpSession stores session data in a DB table named 'YiiSession'. The
table name can be changed by setting CDbHttpSession::$sessionTableName
. If the table does
not exist, it will be automatically created if CDbHttpSession::$autoCreateSessionTable
is
set true.
The following is the table structure:
CREATE TABLE YiiSession ( id CHAR(32) PRIMARY KEY, expire INTEGER, data BLOB )
Where 'BLOB' refers to the BLOB-type of your preffered database.
Note that if your session IDs are more than 32 characters (can be changed via session.hash_bits_per_character or session.hash_function) you should modify SQL schema accordingly.
CDbHttpSession relies on PDO to access database.
By default, it will use an SQLite3 database named 'session-YiiVersion.db'
under the application runtime directory. You can also specify CDbHttpSession::$connectionID
so that it makes use of a DB application component to access
database.
When using CDbHttpSession in a production server, we recommend you pre-create
the session DB table and set CDbHttpSession::$autoCreateSessionTable
to be false. This
will greatly improve the performance. You may also create a DB index for the
'expire' column in the session table to further improve the performance.
- CComponent
- CApplicationComponent implements IApplicationComponent
- CHttpSession implements IteratorAggregate, ArrayAccess, Countable
- CDbHttpSession
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.0
Located at x2engine/framework/web/CDbHttpSession.php
public
boolean
|
#
getUseCustomStorage( )
Returns a value indicating whether to use custom session storage. This method overrides the parent implementation and always returns true. |
public
|
#
regenerateID( boolean $deleteOldSession = false )
Updates the current session id with a newly generated one. Please refer to http://php.net/session_regenerate_id for more details. |
protected
|
|
protected
|
|
public
boolean
|
#
openSession( string $savePath, string $sessionName )
Session open handler. Do not call this method directly. |
public
string
|
|
public
boolean
|
|
public
boolean
|
|
public
boolean
|
getIsInitialized()
|
public
string
|
$connectionID |
|
#
the ID of a |
public
string
|
$sessionTableName | 'YiiSession' |
#
the name of the DB table to store session content. Note, if (id CHAR(32) PRIMARY KEY, expire INTEGER, data BLOB) |
public
boolean
|
$autoCreateSessionTable | true |
#
whether the session DB table should be automatically created if not exists. Defaults to true. |
$autoStart
|
$behaviors
|
public
boolean
|
$useCustomStorage |
#
Whether to use custom storage. |
$cookieMode,
$cookieParams,
$count,
$gCProbability,
$isStarted,
$iterator,
$keys,
$savePath,
$sessionID,
$sessionName,
$timeout,
$useTransparentSessionID
|
$isInitialized
|