system system.base system.caching system.caching.dependencies system.collections system.console system.db system.db.ar system.db.schema system.db.schema.cubrid system.db.schema.mssql system.db.schema.mysql system.db.schema.oci system.db.schema.pgsql system.db.schema.sqlite system.gii system.i18n system.i18n.gettext system.logging system.test system.utils system.validators system.web system.web.actions system.web.auth system.web.filters system.web.form system.web.helpers system.web.renderers system.web.services system.web.widgets system.web.widgets.captcha system.web.widgets.pagers zii.behaviors zii.widgets zii.widgets.grid zii.widgets.jui

CHttpSession

system.web
继承 class CHttpSession » CApplicationComponent » CComponent
实现 IApplicationComponent, IteratorAggregate, Traversable, ArrayAccess, Countable
子类 CCacheHttpSession, CDbHttpSession
可用自 1.0
源码 framework/web/CHttpSession.php
CHttpSession provides session-level data management and the related configurations.

To start the session, call open(); To complete and send out session data, call close(); To destroy the session, call destroy().

If autoStart is set true, the session will be started automatically when the application component is initialized by the application.

CHttpSession can be used like an array to set and get session data. For example,
  $session=new CHttpSession;
  $session->open();
  $value1=$session['name1'];  // get session variable 'name1'
  $value2=$session['name2'];  // get session variable 'name2'
  foreach($session as $name=>$value) // traverse all session variables
  $session['name3']=$value3;  // set session variable 'name3'


The following configurations are available for session: See the corresponding setter and getter documentation for more information. Note, these properties must be set before the session is started.

CHttpSession can be extended to support customized session storage. Override openSession, closeSession, readSession, writeSession, destroySession and gcSession and set useCustomStorage to true. Then, the session data will be stored and retrieved using the above methods.

CHttpSession is a Web application component that can be accessed via CWebApplication::getSession().

公共属性

隐藏继承的属性

属性类型描述被定义在
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
cookieMode string how to use cookie to store session ID. CHttpSession
cookieParams array the session cookie parameters. CHttpSession
count integer Returns the number of items in the session. CHttpSession
gCProbability float the probability (percentage) that the gc (garbage collection) process is started on every session initialization, defaults to 1 meaning 1% chance. CHttpSession
isInitialized boolean Checks if this application component has been initialized. 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 {@link http://php. 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. CHttpSession
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. CHttpSession
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
evaluateExpression() Evaluates a PHP expression or callback under the context of this component. CComponent
gcSession() Session GC (garbage collection) handler. CHttpSession
get() Returns the session variable value with the session variable name. CHttpSession
getCookieMode() Returns how to use cookie to store session ID. Defaults to 'Allow'. CHttpSession
getCookieParams() Returns the session cookie parameters. CHttpSession
getCount() Returns the number of items in the session. CHttpSession
getEventHandlers() Returns the list of attached event handlers for an event. CComponent
getGCProbability() Returns the probability (percentage) that the gc (garbage collection) process is started on every session initialization, defaults to 1 meaning 1% chance. CHttpSession
getIsInitialized() Checks if this application component has been initialized. CApplicationComponent
getIsStarted() Checks whether the session has started CHttpSession
getIterator() Returns an iterator for traversing the session variables. CHttpSession
getKeys() Returns the list of session variable names CHttpSession
getSavePath() Returns the current session save path, defaults to http://php.net/session.save_path. CHttpSession
getSessionID() Returns the current session ID CHttpSession
getSessionName() Returns the current session name CHttpSession
getTimeout() Returns the number of seconds after which data will be seen as 'garbage' and cleaned up, defaults to 1440 seconds. CHttpSession
getUseCustomStorage() Returns a value indicating whether to use custom session storage. CHttpSession
getUseTransparentSessionID() Returns whether transparent sid support is enabled or not, defaults to false. 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. CHttpSession
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. CHttpSession
regenerateID() Updates the current session id with a newly generated one . CHttpSession
remove() Removes a session variable. CHttpSession
setCacheLimiter() Set cache limiter CHttpSession
setCookieMode() Sets how to use cookie to store session ID. Valid values include 'none', 'allow' and 'only'. CHttpSession
setCookieParams() Sets the session cookie parameters. CHttpSession
setGCProbability() Sets the probability (percentage) that the gc (garbage collection) process is started on every session initialization. CHttpSession
setSavePath() Sets the current session save path CHttpSession
setSessionID() Sets the session ID for the current session CHttpSession
setSessionName() Sets the session name for the current session, must be an alphanumeric string, defaults to PHPSESSID CHttpSession
setTimeout() Sets the number of seconds after which data will be seen as 'garbage' and cleaned up CHttpSession
setUseTransparentSessionID() Sets whether transparent sid support is enabled or not. CHttpSession
toArray() CHttpSession
writeSession() Session write handler. CHttpSession

受保护的方法

隐藏继承的方法

方法描述被定义在
freeze() If session is started we cannot edit session ini settings. CHttpSession
unfreeze() Start session and restore data from temporary variable CHttpSession

属性详情

autoStart 属性
public boolean $autoStart;

whether the session should be automatically started when the session application component is initialized, defaults to true.

cookieMode 属性
public string getCookieMode()
public void setCookieMode(string $value)

how to use cookie to store session ID. Defaults to 'Allow'.

cookieParams 属性
public array getCookieParams()
public void setCookieParams(array $value)

the session cookie parameters.

count 属性 只读
public integer getCount()

Returns the number of items in the session.

gCProbability 属性
public float getGCProbability()
public void setGCProbability(float $value)

the probability (percentage) that the gc (garbage collection) process is started on every session initialization, defaults to 1 meaning 1% chance.

isStarted 属性 只读
public boolean getIsStarted()

whether the session has started

iterator 属性 只读

Returns an iterator for traversing the session variables. This method is required by the interface IteratorAggregate.

keys 属性 只读
public array getKeys()

the list of session variable names

savePath 属性
public string getSavePath()
public void setSavePath(string $value)

the current session save path, defaults to http://php.net/session.save_path.

sessionID 属性
public string getSessionID()
public void setSessionID(string $value)

the current session ID

sessionName 属性
public string getSessionName()
public void setSessionName(string $value)

the current session name

timeout 属性
public integer getTimeout()
public void setTimeout(integer $value)

the number of seconds after which data will be seen as 'garbage' and cleaned up, defaults to 1440 seconds.

useCustomStorage 属性 只读
public boolean getUseCustomStorage()

Returns a value indicating whether to use custom session storage. This method should be overridden to return true if custom session storage handler should be used. If returning true, make sure the methods openSession, closeSession, readSession, writeSession, destroySession, and gcSession are overridden in child class, because they will be used as the callback handlers. The default implementation always return false.

useTransparentSessionID 属性
public boolean getUseTransparentSessionID()
public void setUseTransparentSessionID(boolean $value)

whether transparent sid support is enabled or not, defaults to false.

方法详情

add() 方法
public void add(mixed $key, mixed $value)
$key mixed session variable name
$value mixed session variable value
源码: framework/web/CHttpSession.php#504 (显示)
public function add($key,$value)
{
    
$_SESSION[$key]=$value;
}

Adds a session variable. Note, if the specified name already exists, the old value will be removed first.

clear() 方法
public void clear()
源码: framework/web/CHttpSession.php#529 (显示)
public function clear()
{
    foreach(
array_keys($_SESSION) as $key)
        unset(
$_SESSION[$key]);
}

Removes all session variables

close() 方法
public void close()
源码: framework/web/CHttpSession.php#137 (显示)
public function close()
{
    if(
session_id()!=='')
        @
session_write_close();
}

Ends the current session and store session data.

closeSession() 方法
public boolean closeSession()
{return} boolean whether session is closed successfully
源码: framework/web/CHttpSession.php#380 (显示)
public function closeSession()
{
    return 
true;
}

Session close handler. This method should be overridden if useCustomStorage is set true. Do not call this method directly.

contains() 方法
public boolean contains(mixed $key)
$key mixed session variable name
{return} boolean whether there is the named session variable
源码: framework/web/CHttpSession.php#539 (显示)
public function contains($key)
{
    return isset(
$_SESSION[$key]);
}

count() 方法
public integer count()
{return} integer number of items in the session.
源码: framework/web/CHttpSession.php#460 (显示)
public function count()
{
    return 
$this->getCount();
}

Returns the number of items in the session. This method is required by Countable interface.

destroy() 方法
public void destroy()
源码: framework/web/CHttpSession.php#146 (显示)
public function destroy()
{
    if(
session_id()!=='')
    {
        @
session_unset();
        @
session_destroy();
    }
}

Frees all session variables and destroys all data registered to a session.

destroySession() 方法
public boolean destroySession(string $id)
$id string session ID
{return} boolean whether session is destroyed successfully
源码: framework/web/CHttpSession.php#417 (显示)
public function destroySession($id)
{
    return 
true;
}

Session destroy handler. This method should be overridden if useCustomStorage is set true. Do not call this method directly.

freeze() 方法 (自版本 v1.1.20 可用)
protected void freeze()
源码: framework/web/CHttpSession.php#598 (显示)
protected function freeze()
{
    if (isset(
$_SESSION) && $this->getIsStarted())
    {
        
$this->_frozenData $_SESSION;
        
$this->close();
    }
}

If session is started we cannot edit session ini settings. This function save session data to temporary variable and stop session.

参见

  • CHttpSession::unfreeze();
gcSession() 方法
public boolean gcSession(integer $maxLifetime)
$maxLifetime integer the number of seconds after which data will be seen as 'garbage' and cleaned up.
{return} boolean whether session is GCed successfully
源码: framework/web/CHttpSession.php#429 (显示)
public function gcSession($maxLifetime)
{
    return 
true;
}

Session GC (garbage collection) handler. This method should be overridden if useCustomStorage is set true. Do not call this method directly.

get() 方法 (自版本 v1.1.2 可用)
public mixed get(mixed $key, mixed $defaultValue=NULL)
$key mixed the session variable name
$defaultValue mixed the default value to be returned when the session variable does not exist.
{return} mixed the session variable value, or $defaultValue if the session variable does not exist.
源码: framework/web/CHttpSession.php#482 (显示)
public function get($key,$defaultValue=null)
{
    return isset(
$_SESSION[$key]) ? $_SESSION[$key] : $defaultValue;
}

Returns the session variable value with the session variable name. This method is very similar to itemAt and offsetGet, except that it will return $defaultValue if the session variable does not exist.

getCookieMode() 方法
public string getCookieMode()
{return} string how to use cookie to store session ID. Defaults to 'Allow'.
源码: framework/web/CHttpSession.php#261 (显示)
public function getCookieMode()
{
    if(
ini_get('session.use_cookies')==='0')
        return 
'none';
    elseif(
ini_get('session.use_only_cookies')==='0')
        return 
'allow';
    else
        return 
'only';
}

getCookieParams() 方法
public array getCookieParams()
{return} array the session cookie parameters.
源码: framework/web/CHttpSession.php#234 (显示)
public function getCookieParams()
{
    return 
session_get_cookie_params();
}

getCount() 方法
public integer getCount()
{return} integer the number of session variables
源码: framework/web/CHttpSession.php#450 (显示)
public function getCount()
{
    return 
count($_SESSION);
}

Returns the number of items in the session.

getGCProbability() 方法
public float getGCProbability()
{return} float the probability (percentage) that the gc (garbage collection) process is started on every session initialization, defaults to 1 meaning 1% chance.
源码: framework/web/CHttpSession.php#305 (显示)
public function getGCProbability()
{
    return (float)(
ini_get('session.gc_probability')/ini_get('session.gc_divisor')*100);
}

getIsStarted() 方法
public boolean getIsStarted()
{return} boolean whether the session has started
源码: framework/web/CHttpSession.php#158 (显示)
public function getIsStarted()
{
    if(
function_exists('session_status'))
        return 
session_status()===PHP_SESSION_ACTIVE;
    return 
session_id()!=='';
}

getIterator() 方法
public CHttpSessionIterator getIterator()
{return} CHttpSessionIterator an iterator for traversing the session variables.
源码: framework/web/CHttpSession.php#441 (显示)
public function getIterator()
{
    return new 
CHttpSessionIterator;
}

Returns an iterator for traversing the session variables. This method is required by the interface IteratorAggregate.

getKeys() 方法
public array getKeys()
{return} array the list of session variable names
源码: framework/web/CHttpSession.php#468 (显示)
public function getKeys()
{
    return 
array_keys($_SESSION);
}

getSavePath() 方法
public string getSavePath()
{return} string the current session save path, defaults to http://php.net/session.save_path.
源码: framework/web/CHttpSession.php#212 (显示)
public function getSavePath()
{
    return 
session_save_path();
}

getSessionID() 方法
public string getSessionID()
{return} string the current session ID
源码: framework/web/CHttpSession.php#168 (显示)
public function getSessionID()
{
    return 
session_id();
}

getSessionName() 方法
public string getSessionName()
{return} string the current session name
源码: framework/web/CHttpSession.php#196 (显示)
public function getSessionName()
{
    return 
session_name();
}

getTimeout() 方法
public integer getTimeout()
{return} integer the number of seconds after which data will be seen as 'garbage' and cleaned up, defaults to 1440 seconds.
源码: framework/web/CHttpSession.php#348 (显示)
public function getTimeout()
{
    return (int)
ini_get('session.gc_maxlifetime');
}

getUseCustomStorage() 方法
public boolean getUseCustomStorage()
{return} boolean whether to use custom storage.
源码: framework/web/CHttpSession.php#107 (显示)
public function getUseCustomStorage()
{
    return 
false;
}

Returns a value indicating whether to use custom session storage. This method should be overridden to return true if custom session storage handler should be used. If returning true, make sure the methods openSession, closeSession, readSession, writeSession, destroySession, and gcSession are overridden in child class, because they will be used as the callback handlers. The default implementation always return false.

getUseTransparentSessionID() 方法
public boolean getUseTransparentSessionID()
{return} boolean whether transparent sid support is enabled or not, defaults to false.
源码: framework/web/CHttpSession.php#332 (显示)
public function getUseTransparentSessionID()
{
    return 
ini_get('session.use_trans_sid')==1;
}

init() 方法
public void init()
源码: framework/web/CHttpSession.php#89 (显示)
public function init()
{
    
parent::init();

    if(
$this->autoStart)
        
$this->open();
    
register_shutdown_function(array($this,'close'));
}

Initializes the application component. This method is required by IApplicationComponent and is invoked by application.

itemAt() 方法
public mixed itemAt(mixed $key)
$key mixed the session variable name
{return} mixed the session variable value, null if no such variable exists
源码: framework/web/CHttpSession.php#493 (显示)
public function itemAt($key)
{
    return isset(
$_SESSION[$key]) ? $_SESSION[$key] : null;
}

Returns the session variable value with the session variable name. This method is exactly the same as offsetGet.

offsetExists() 方法
public boolean offsetExists(mixed $offset)
$offset mixed the offset to check on
{return} boolean
源码: framework/web/CHttpSession.php#557 (显示)
public function offsetExists($offset)
{
    return isset(
$_SESSION[$offset]);
}

This method is required by the interface ArrayAccess.

offsetGet() 方法
public mixed offsetGet(integer $offset)
$offset integer the offset to retrieve element.
{return} mixed the element at the offset, null if no element is found at the offset
源码: framework/web/CHttpSession.php#567 (显示)
public function offsetGet($offset)
{
    return isset(
$_SESSION[$offset]) ? $_SESSION[$offset] : null;
}

This method is required by the interface ArrayAccess.

offsetSet() 方法
public void offsetSet(integer $offset, mixed $item)
$offset integer the offset to set element
$item mixed the element value
源码: framework/web/CHttpSession.php#577 (显示)
public function offsetSet($offset,$item)
{
    
$_SESSION[$offset]=$item;
}

This method is required by the interface ArrayAccess.

offsetUnset() 方法
public void offsetUnset(mixed $offset)
$offset mixed the offset to unset element
源码: framework/web/CHttpSession.php#586 (显示)
public function offsetUnset($offset)
{
    unset(
$_SESSION[$offset]);
}

This method is required by the interface ArrayAccess.

open() 方法
public void open()
源码: framework/web/CHttpSession.php#115 (显示)
public function open()
{
    if(
$this->getUseCustomStorage())
        @
session_set_save_handler(array($this,'openSession'),array($this,'closeSession'),array($this,'readSession'),array($this,'writeSession'),array($this,'destroySession'),array($this,'gcSession'));

    @
session_start();
    if(
YII_DEBUG && session_id()=='')
    {
        
$message=Yii::t('yii','Failed to start session.');
        if(
function_exists('error_get_last'))
        {
            
$error=error_get_last();
            if(isset(
$error['message']))
                
$message=$error['message'];
        }
        
Yii::log($messageCLogger::LEVEL_WARNING'system.web.CHttpSession');
    }
}

Starts the session if it has not started yet.

openSession() 方法
public boolean openSession(string $savePath, string $sessionName)
$savePath string session save path
$sessionName string session name
{return} boolean whether session is opened successfully
源码: framework/web/CHttpSession.php#369 (显示)
public function openSession($savePath,$sessionName)
{
    return 
true;
}

Session open handler. This method should be overridden if useCustomStorage is set true. Do not call this method directly.

readSession() 方法
public string readSession(string $id)
$id string session ID
{return} string the session data
源码: framework/web/CHttpSession.php#392 (显示)
public function readSession($id)
{
    return 
'';
}

Session read handler. This method should be overridden if useCustomStorage is set true. Do not call this method directly.

regenerateID() 方法 (自版本 v1.1.8 可用)
public void regenerateID(boolean $deleteOldSession=false)
$deleteOldSession boolean Whether to delete the old associated session file or not.
源码: framework/web/CHttpSession.php#187 (显示)
public function regenerateID($deleteOldSession=false)
{
    if(
$this->getIsStarted())
        
session_regenerate_id($deleteOldSession);
}

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

remove() 方法
public mixed remove(mixed $key)
$key mixed the name of the session variable to be removed
{return} mixed the removed value, null if no such session variable.
源码: framework/web/CHttpSession.php#514 (显示)
public function remove($key)
{
    if(isset(
$_SESSION[$key]))
    {
        
$value=$_SESSION[$key];
        unset(
$_SESSION[$key]);
        return 
$value;
    }
    else
        return 
null;
}

Removes a session variable.

setCacheLimiter() 方法 (自版本 v1.1.20 可用)
public void setCacheLimiter(string $cacheLimiter)
$cacheLimiter string
源码: framework/web/CHttpSession.php#629 (显示)
public function setCacheLimiter($cacheLimiter)
{
    
$this->freeze();
    
session_cache_limiter($cacheLimiter);
    
$this->unfreeze();
}

Set cache limiter

setCookieMode() 方法
public void setCookieMode(string $value)
$value string how to use cookie to store session ID. Valid values include 'none', 'allow' and 'only'.
源码: framework/web/CHttpSession.php#275 (显示)
public function setCookieMode($value)
{
    if(
$value==='none')
    {
        
$this->freeze();
        
ini_set('session.use_cookies','0');
        
ini_set('session.use_only_cookies','0');
        
$this->unfreeze();
    }
    elseif(
$value==='allow')
    {
        
$this->freeze();
        
ini_set('session.use_cookies','1');
        
ini_set('session.use_only_cookies','0');
        
$this->unfreeze();
    }
    elseif(
$value==='only')
    {
        
$this->freeze();
        
ini_set('session.use_cookies','1');
        
ini_set('session.use_only_cookies','1');
        
$this->unfreeze();
    }
    else
        throw new 
CException(Yii::t('yii','CHttpSession.cookieMode can only be "none", "allow" or "only".'));
}

setCookieParams() 方法
public void setCookieParams(array $value)
$value array cookie parameters, valid keys include: lifetime, path, domain, secure, httponly. Note that httponly is all lowercase.
源码: framework/web/CHttpSession.php#247 (显示)
public function setCookieParams($value)
{
    
$data=session_get_cookie_params();
    
extract($data);
    
extract($value);
    if(isset(
$httponly))
        
session_set_cookie_params($lifetime,$path,$domain,$secure,$httponly);
    else
        
session_set_cookie_params($lifetime,$path,$domain,$secure);
}

Sets the session cookie parameters. The effect of this method only lasts for the duration of the script. Call this method before the session starts.

setGCProbability() 方法
public void setGCProbability(float $value)
$value float the probability (percentage) that the gc (garbage collection) process is started on every session initialization.
源码: framework/web/CHttpSession.php#314 (显示)
public function setGCProbability($value)
{
    if(
$value>=&& $value<=100)
    {
        
$this->freeze();
        
// percent * 21474837 / 2147483647 ≈ percent * 0.01
        
ini_set('session.gc_probability',floor($value*21474836.47));
        
ini_set('session.gc_divisor',2147483647);
        
$this->unfreeze();
    }
    else
        throw new 
CException(Yii::t('yii','CHttpSession.gcProbability "{value}" is invalid. It must be a float between 0 and 100.',
            array(
'{value}'=>$value)));
}

setSavePath() 方法
public void setSavePath(string $value)
$value string the current session save path
源码: framework/web/CHttpSession.php#221 (显示)
public function setSavePath($value)
{
    if(
is_dir($value))
        
session_save_path($value);
    else
        throw new 
CException(Yii::t('yii','CHttpSession.savePath "{path}" is not a valid directory.',
            array(
'{path}'=>$value)));
}

setSessionID() 方法
public void setSessionID(string $value)
$value string the session ID for the current session
源码: framework/web/CHttpSession.php#176 (显示)
public function setSessionID($value)
{
    
session_id($value);
}

setSessionName() 方法
public void setSessionName(string $value)
$value string the session name for the current session, must be an alphanumeric string, defaults to PHPSESSID
源码: framework/web/CHttpSession.php#204 (显示)
public function setSessionName($value)
{
    
session_name($value);
}

setTimeout() 方法
public void setTimeout(integer $value)
$value integer the number of seconds after which data will be seen as 'garbage' and cleaned up
源码: framework/web/CHttpSession.php#356 (显示)
public function setTimeout($value)
{
    
ini_set('session.gc_maxlifetime',$value);
}

setUseTransparentSessionID() 方法
public void setUseTransparentSessionID(boolean $value)
$value boolean whether transparent sid support is enabled or not.
源码: framework/web/CHttpSession.php#340 (显示)
public function setUseTransparentSessionID($value)
{
    
ini_set('session.use_trans_sid',$value?'1':'0');
}

toArray() 方法
public array toArray()
{return} array the list of all session variables in array
源码: framework/web/CHttpSession.php#547 (显示)
public function toArray()
{
    return 
$_SESSION;
}

unfreeze() 方法 (自版本 v1.1.20 可用)
protected void unfreeze()
源码: framework/web/CHttpSession.php#613 (显示)
protected function unfreeze()
{
    if (
$this->_frozenData !== null)
    {
        @
session_start();
        
$_SESSION $this->_frozenData;
        
$this->_frozenData null;
    }
}

Start session and restore data from temporary variable

参见

  • CHttpSession::freeze();
writeSession() 方法
public boolean writeSession(string $id, string $data)
$id string session ID
$data string session data
{return} boolean whether session write is successful
源码: framework/web/CHttpSession.php#405 (显示)
public function writeSession($id,$data)
{
    return 
true;
}

Session write handler. This method should be overridden if useCustomStorage is set true. Do not call this method directly.