system system.base system.caching system.caching.dependencies system.collections system.console system.db system.db.ar system.db.schema system.db.schema.mssql system.db.schema.mysql system.db.schema.oci system.db.schema.pgsql system.db.schema.sqlite system.i18n system.i18n.gettext system.logging system.utils system.validators system.web system.web.actions system.web.auth system.web.filters system.web.helpers system.web.renderers system.web.services system.web.widgets system.web.widgets.captcha system.web.widgets.pagers

CCacheHttpSession

system.web
继承 class CCacheHttpSession » CHttpSession » CApplicationComponent » CComponent
实现 Countable, ArrayAccess, Traversable, IteratorAggregate, IApplicationComponent
可用自 1.0
版本 $Id$
CCacheHttpSession implements a session component using cache as storage medium.

The cache being used can be any cache application component implementing ICache interface. The ID of the cache application component is specified via cacheID, which defaults to 'cache'.

Beware, by definition cache storage are volatile, which means the data stored on them may be swapped out and get lost. Therefore, you must make sure the cache used by this component is NOT volatile. If you want to use CDbCache as storage medium, use CDbHttpSession is a better choice.

公共属性

隐藏继承的属性

属性类型描述被定义在
autoStart boolean whether the session should be automatically started when the session application component is initialized, defaults to true. CHttpSession
behaviors array the behaviors that should be attached to this component. CApplicationComponent
cacheID string the ID of the cache application component. CCacheHttpSession
cookieMode string how to use cookie to store session ID. CHttpSession
cookieParams array the session cookie parameters. CHttpSession
count integer the number of session variables CHttpSession
gCProbability integer the probability (percentage) that the gc (garbage collection) process is started on every session initialization, defaults to 1 meaning 1% chance. CHttpSession
isInitialized boolean whether this application component has been initialized (i. CApplicationComponent
isStarted boolean whether the session has started CHttpSession
iterator CHttpSessionIterator Returns an iterator for traversing the session variables. CHttpSession
keys array the list of session variable names CHttpSession
savePath string the current session save path, defaults to '/tmp'. CHttpSession
sessionID string the current session ID CHttpSession
sessionName string the current session name CHttpSession
timeout integer the number of seconds after which data will be seen as 'garbage' and cleaned up, defaults to 1440 seconds. CHttpSession
useCustomStorage boolean Returns a value indicating whether to use custom session storage. CCacheHttpSession
useTransparentSessionID boolean whether transparent sid support is enabled or not, defaults to false. CHttpSession

公共方法

隐藏继承的方法

方法描述被定义在
__call() Calls the named method which is not a class method. CComponent
__get() Returns a property value, an event handler list or a behavior based on its name. CComponent
__isset() Checks if a property value is null. CComponent
__set() Sets value of a component property. CComponent
__unset() Sets a component property to be null. CComponent
add() Adds a session variable. CHttpSession
asa() Returns the named behavior object. CComponent
attachBehavior() Attaches a behavior to this component. CComponent
attachBehaviors() Attaches a list of behaviors to the component. CComponent
attachEventHandler() Attaches an event handler to an event. CComponent
canGetProperty() Determines whether a property can be read. CComponent
canSetProperty() Determines whether a property can be set. CComponent
clear() Removes all session variables CHttpSession
close() Ends the current session and store session data. CHttpSession
closeSession() Session close handler. CHttpSession
contains() CHttpSession
count() Returns the number of items in the session. CHttpSession
destroy() Frees all session variables and destroys all data registered to a session. CHttpSession
destroySession() Session destroy handler. CCacheHttpSession
detachBehavior() Detaches a behavior from the component. CComponent
detachBehaviors() Detaches all behaviors from the component. CComponent
detachEventHandler() Detaches an existing event handler. CComponent
disableBehavior() Disables an attached behavior. CComponent
disableBehaviors() Disables all behaviors attached to this component. CComponent
enableBehavior() Enables an attached behavior. CComponent
enableBehaviors() Enables all behaviors attached to this component. CComponent
gcSession() Session GC (garbage collection) handler. CHttpSession
getCookieMode() CHttpSession
getCookieParams() CHttpSession
getCount() CHttpSession
getEventHandlers() Returns the list of attached event handlers for an event. CComponent
getGCProbability() CHttpSession
getIsInitialized() CApplicationComponent
getIsStarted() CHttpSession
getIterator() Returns an iterator for traversing the session variables. CHttpSession
getKeys() CHttpSession
getSavePath() CHttpSession
getSessionID() CHttpSession
getSessionName() CHttpSession
getTimeout() CHttpSession
getUseCustomStorage() Returns a value indicating whether to use custom session storage. CCacheHttpSession
getUseTransparentSessionID() CHttpSession
hasEvent() Determines whether an event is defined. CComponent
hasEventHandler() Checks whether the named event has attached handlers. CComponent
hasProperty() Determines whether a property is defined. CComponent
init() Initializes the application component. CCacheHttpSession
itemAt() Returns the session variable value with the session variable name. CHttpSession
offsetExists() This method is required by the interface ArrayAccess. CHttpSession
offsetGet() This method is required by the interface ArrayAccess. CHttpSession
offsetSet() This method is required by the interface ArrayAccess. CHttpSession
offsetUnset() This method is required by the interface ArrayAccess. CHttpSession
open() Starts the session if it has not started yet. CHttpSession
openSession() Session open handler. CHttpSession
raiseEvent() Raises an event. CComponent
readSession() Session read handler. CCacheHttpSession
remove() Removes a session variable. CHttpSession
setCookieMode() CHttpSession
setCookieParams() Sets the session cookie parameters. CHttpSession
setGCProbability() CHttpSession
setSavePath() CHttpSession
setSessionID() CHttpSession
setSessionName() CHttpSession
setTimeout() CHttpSession
setUseTransparentSessionID() CHttpSession
toArray() CHttpSession
writeSession() Session write handler. CCacheHttpSession

受保护的方法

隐藏继承的方法

方法描述被定义在
calculateKey() Generates a unique key used for storing session data in cache. CCacheHttpSession

属性详情

cacheID 属性
public string $cacheID;

the ID of the cache application component. Defaults to 'cache' (the primary cache application component.)

useCustomStorage 属性 只读
public boolean getUseCustomStorage()

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

方法详情

calculateKey() 方法
protected string calculateKey(string $id)
$id string session variable name
{return} string a safe cache key associated with the session variable name

Generates a unique key used for storing session data in cache.

destroySession() 方法
public boolean destroySession(string $id)
$id string session ID
{return} boolean whether session is destroyed successfully

Session destroy handler. Do not call this method directly.

getUseCustomStorage() 方法
public boolean getUseCustomStorage()
{return} boolean whether to use custom storage.

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

init() 方法
public void init()

Initializes the application component. This method overrides the parent implementation by checking if cache is available.

readSession() 方法
public string readSession(string $id)
$id string session ID
{return} string the session data

Session read handler. Do not call this method directly.

writeSession() 方法
public boolean writeSession(string $id, string $data)
$id string session ID
$data string session data
{return} boolean whether session write is successful

Session write handler. Do not call this method directly.