- Home
- About
- Testimonials
- Demos
- Download
- Documentation
- Blogs
- Forum
- Support

Packages:
default
System
System.Caching
System.Collections
System.Data
System.Data.ActiveRecord
System.Data.ActiveRecord.Relations
System.Data.ActiveRecord.Scaffold
System.Data.ActiveReecord.Scaffold.InputBuilder
System.Data.Commom.Sqlite
System.Data.Common
System.Data.Common.Mssql
System.Data.Common.Mysql
System.Data.Common.Oracle
System.Data.Common.Pgsql
System.Data.Common.Sqlite
System.Data.DataGateway
System.Data.SqlMap
System.Data.SqlMap.Configuration
System.Data.SqlMap.Statements
System.Exceptions
System.I18N
System.IO
System.Security
System.Util
System.Web
System.Web.Services
System.Web.UI
System.Web.UI.ActiveControls
System.Web.UI.WebControls
System.Web.UI.WebControls.assets
System.Xml
Classes:
TAssetManager
TCacheHttpSession
THttpCookie
THttpCookieCollection
THttpRequest
THttpRequestUrlFormat
THttpResponse
THttpResponseAdapter
THttpSession
THttpSessionCookieMode
THttpUtility
TSessionIterator
TUri
TUrlManager
TUrlMapping
TUrlMappingPattern

Keyword

# Class TCacheHttpSession

    TComponent
       |
       --TApplicationComponent
          |
          --THttpSession
             |
             --TCacheHttpSession

TCacheHttpSession class

TCacheHttpSession provides access for storing session data using a cache module (e.g. TMemCache, TDbCache). To specify the cache module for data storage, set the CacheModuleID property which should refer to a valid cache module configured in the application configuration.

The following example shows how we configure TCacheHttpSession:

      <modules>
        <module id="cache" class="System.Caching.TMemCache" Host="localhost" Port="11211" />
        <module id="session" class="System.Web.TCacheHttpSession"
             CacheModuleID="cache" SessionName="SSID"
             CookieMode="Allow" AutoStart="true" GCProbability="1"
             UseTransparentSessionID="true" TimeOut="3600" />
      </modules>

Beware, by definition cache storage are volatile, which means the data stored on them may be swapped out and get lost. This may not be the case for certain cache storage, such as database. So make sure you manage your cache properly to avoid loss of session data.

Since: 3.1.1
Author: Carl G. Mathisen <carlgmathisen@gmail.com>
Author: Qiang Xue <qiang.xue@gmail.com>

Method Summary
protected string | calculateKey ( string $id)
ICache | getCache ()
string | getCacheModuleID ()
string | getKeyPrefix ()
void | init ( TXmlElement $config) Initializes the module.
void | setCacheModuleID ( string $value)
void | setKeyPrefix ( string $value)
boolean | _destroy ( string $id) Session destroy handler.
string | _read ( string $id) Session read handler.
boolean | _write ( string $id, string $data) Session write handler.

Methods Inherited From THttpSession

THttpSession::add(), THttpSession::clear(), THttpSession::close(), THttpSession::contains(), THttpSession::count(), THttpSession::destroy(), THttpSession::getAutoStart(), THttpSession::getCookie(), THttpSession::getCookieMode(), THttpSession::getCount(), THttpSession::getGCProbability(), THttpSession::getID(), THttpSession::getIsStarted(), THttpSession::getIterator(), THttpSession::getKeys(), THttpSession::getSavePath(), THttpSession::getSessionID(), THttpSession::getSessionName(), THttpSession::getTimeout(), THttpSession::getUseCustomStorage(), THttpSession::getUseTransparentSessionID(), THttpSession::init(), THttpSession::itemAt(), THttpSession::offsetExists(), THttpSession::offsetGet(), THttpSession::offsetSet(), THttpSession::offsetUnset(), THttpSession::open(), THttpSession::remove(), THttpSession::setAutoStart(), THttpSession::setCookieMode(), THttpSession::setGCProbability(), THttpSession::setID(), THttpSession::setSavePath(), THttpSession::setSessionID(), THttpSession::setSessionName(), THttpSession::setTimeout(), THttpSession::setUseCustomStorage(), THttpSession::setUseTransparentSessionID(), THttpSession::toArray(), THttpSession::_close(), THttpSession::_destroy(), THttpSession::_gc(), THttpSession::_open(), THttpSession::_read(), THttpSession::_write()

Methods Inherited From TApplicationComponent
TApplicationComponent::getApplication(), TApplicationComponent::getRequest(), TApplicationComponent::getResponse(), TApplicationComponent::getService(), TApplicationComponent::getSession(), TApplicationComponent::getUser(), TApplicationComponent::publishAsset(), TApplicationComponent::publishFilePath()

Methods Inherited From TComponent

TComponent::addParsedObject(), TComponent::attachEventHandler(), TComponent::canGetProperty(), TComponent::canSetProperty(), TComponent::createdOnTemplate(), TComponent::detachEventHandler(), TComponent::evaluateExpression(), TComponent::evaluateStatements(), TComponent::getEventHandlers(), TComponent::getSubProperty(), TComponent::hasEvent(), TComponent::hasEventHandler(), TComponent::hasProperty(), TComponent::raiseEvent(), TComponent::setSubProperty(), TComponent::__get(), TComponent::__set()

Method Details

## calculateKey

protected string calculateKey | (string $id )

Input
string | $id | session variable name
Output
string | a safe cache key associated with the session variable name
Exception

## getCache

public ICache getCache | ()

Output
ICache | the cache module being used for data storage
Exception

## getCacheModuleID

public string getCacheModuleID | ()

Output
string | the ID of the cache module.
Exception

## getKeyPrefix

public string getKeyPrefix | ()

Output
string | prefix of session variable name to avoid conflict with other cache data. Defaults to 'session'.
Exception

## init

public void init | (TXmlElement $config )

Initializes the module.

This method is required by IModule. It reads the CacheModule property.

Input
TXmlElement | $config | module configuration
Output
Exception

## setCacheModuleID

public void setCacheModuleID | (string $value )

Input
string | $value | the ID of the cache module.
Output
Exception

## setKeyPrefix

public void setKeyPrefix | (string $value )

Input
string | $value | prefix of session variable name to avoid conflict with other cache data
Output
Exception

## _destroy

public boolean _destroy | (string $id )

Session destroy handler.

This method should be overriden if UseCustomStorage is set true.

Input
string | $id | session ID
Output
boolean | whether session is destroyed successfully
Exception

## _read

public string _read | (string $id )

Session read handler.

Input
string | $id | session ID
Output
string | the session data
Exception

## _write

public boolean _write | (string $id , string $data )

Session write handler.

Input
string | $id | session ID
string | $data | session data
Output
boolean | whether session write is successful
Exception