Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • ActionFormModelBase
  • CActiveDataProvider
  • CalendarEventFormModel
  • CallFormModel
  • CArrayDataProvider
  • CAssetManager
  • CBaseController
  • CBaseUrlRule
  • CCacheHttpSession
  • CClientScript
  • CController
  • CCookieCollection
  • CDataProvider
  • CDataProviderIterator
  • CDbHttpSession
  • CExtController
  • CFormModel
  • CHttpCookie
  • CHttpRequest
  • CHttpSession
  • CHttpSessionIterator
  • COutputEvent
  • CPagination
  • CreatePageFormModel
  • CSort
  • CSqlDataProvider
  • CTheme
  • CThemeManager
  • CUploadedFile
  • CUrlManager
  • CUrlRule
  • CWebApplication
  • CWebModule
  • CWidgetFactory
  • EditMobileFormsFormModel
  • EventCommentPublisherFormModel
  • EventFormModel
  • EventPublisherFormModel
  • FileSystemObjectDataProvider
  • MassActionFormModel
  • MobilePagination
  • NoteFormModel
  • NotificationsController
  • TimeFormModel
  • UploadLogoFormModel
  • X2FormModel
  • X2HttpRequest

Interfaces

  • IDataProvider
  • IWidgetFactory
  • Overview
  • Package
  • Class
  • Tree

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
Extended by CApplicationComponent implements IApplicationComponent
Extended by CHttpSession implements IteratorAggregate, ArrayAccess, Countable
Extended by CDbHttpSession
Package: system\web
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
Methods summary
public boolean
# getUseCustomStorage( )

Returns a value indicating whether to use custom session storage. This method overrides the parent implementation and always returns true.

Returns a value indicating whether to use custom session storage. This method overrides the parent implementation and always returns true.

Returns

boolean
whether to use custom storage.

Overrides

CHttpSession::getUseCustomStorage()
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.

Updates the current session id with a newly generated one. Please refer to http://php.net/session_regenerate_id for more details.

Parameters

$deleteOldSession
boolean
$deleteOldSession Whether to delete the old associated session file or not.

Since

1.1.8

Overrides

CHttpSession::regenerateID()
protected
# createSessionTable( CDbConnection $db, string $tableName )

Creates the session DB table.

Creates the session DB table.

Parameters

$db
CDbConnection
$db the database connection
$tableName
string
$tableName the name of the table to be created
protected CDbConnection
# getDbConnection( )

Returns

CDbConnection
the DB connection instance

Throws

CException
if CDbHttpSession::$connectionID does not point to a valid application component.
public boolean
# openSession( string $savePath, string $sessionName )

Session open handler. Do not call this method directly.

Session open handler. Do not call this method directly.

Parameters

$savePath
string
$savePath session save path
$sessionName
string
$sessionName session name

Returns

boolean
whether session is opened successfully

Overrides

CHttpSession::openSession()
public string
# readSession( string $id )

Session read handler. Do not call this method directly.

Session read handler. Do not call this method directly.

Parameters

$id
string
$id session ID

Returns

string
the session data

Overrides

CHttpSession::readSession()
public boolean
# writeSession( string $id, string $data )

Session write handler. Do not call this method directly.

Session write handler. Do not call this method directly.

Parameters

$id
string
$id session ID
$data
string
$data session data

Returns

boolean
whether session write is successful

Overrides

CHttpSession::writeSession()
public boolean
# destroySession( string $id )

Session destroy handler. Do not call this method directly.

Session destroy handler. Do not call this method directly.

Parameters

$id
string
$id session ID

Returns

boolean
whether session is destroyed successfully

Overrides

CHttpSession::destroySession()
public boolean
# gcSession( integer $maxLifetime )

Session GC (garbage collection) handler. Do not call this method directly.

Session GC (garbage collection) handler. Do not call this method directly.

Parameters

$maxLifetime
integer
$maxLifetime the number of seconds after which data will be seen as 'garbage' and cleaned up.

Returns

boolean
whether session is GCed successfully

Overrides

CHttpSession::gcSession()
Methods inherited from CHttpSession
add(), clear(), close(), closeSession(), contains(), count(), destroy(), get(), getCookieMode(), getCookieParams(), getCount(), getGCProbability(), getIsStarted(), getIterator(), getKeys(), getSavePath(), getSessionID(), getSessionName(), getTimeout(), getUseTransparentSessionID(), init(), itemAt(), offsetExists(), offsetGet(), offsetSet(), offsetUnset(), open(), remove(), setCookieMode(), setCookieParams(), setGCProbability(), setSavePath(), setSessionID(), setSessionName(), setTimeout(), setUseTransparentSessionID(), toArray()
Methods inherited from CApplicationComponent
getIsInitialized()
Methods inherited from CComponent
__call(), __get(), __isset(), __set(), __unset(), asa(), attachBehavior(), attachBehaviors(), attachEventHandler(), canGetProperty(), canSetProperty(), detachBehavior(), detachBehaviors(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), getEventHandlers(), hasEvent(), hasEventHandler(), hasProperty(), raiseEvent()
Properties summary
public string $connectionID
#

the ID of a CDbConnection application component. If not set, a SQLite database will be automatically created and used. The SQLite database file is is <span class="php-keyword1">protected</span>/runtime/session-YiiVersion.db.

the ID of a CDbConnection application component. If not set, a SQLite database will be automatically created and used. The SQLite database file is is <span class="php-keyword1">protected</span>/runtime/session-YiiVersion.db.

public string $sessionTableName 'YiiSession'
#

the name of the DB table to store session content. Note, if CDbHttpSession::$autoCreateSessionTable is false and you want to create the DB table manually by yourself, you need to make sure the DB table is of the following structure:

(id CHAR(32) PRIMARY KEY, expire INTEGER, data BLOB)

the name of the DB table to store session content. Note, if CDbHttpSession::$autoCreateSessionTable is false and you want to create the DB table manually by yourself, you need to make sure the DB table is of the following structure:

(id CHAR(32) PRIMARY KEY, expire INTEGER, data BLOB)

See

CDbHttpSession::$autoCreateSessionTable
public boolean $autoCreateSessionTable true
#

whether the session DB table should be automatically created if not exists. Defaults to true.

whether the session DB table should be automatically created if not exists. Defaults to true.

See

CDbHttpSession::$sessionTableName
Properties inherited from CHttpSession
$autoStart
Properties inherited from CApplicationComponent
$behaviors
Magic properties summary
public boolean $useCustomStorage
#

Whether to use custom storage.

Whether to use custom storage.

Magic properties inherited from CHttpSession
$cookieMode, $cookieParams, $count, $gCProbability, $isStarted, $iterator, $keys, $savePath, $sessionID, $sessionName, $timeout, $useTransparentSessionID
Magic properties inherited from CApplicationComponent
$isInitialized
API documentation generated by ApiGen 2.8.0