thrownewCException(Yii::t('yii','DbSession.connectionID "{id}" is invalid. Please make sure it refers to the ID of a CDbConnection application component.',
* {@link writeSession}, {@link destroySession} and {@link gcSession}
* and set {@link useCustomStorage} to true.
* 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
* Session is a Web application component that can be accessed via
* {@link CWebApplication::getSession()}.
*
* @property boolean $useCustomStorage Whether to use custom storage.
...
...
@@ -58,26 +62,23 @@
* @property string $savePath The current session save path, defaults to '/tmp'.
* @property array $cookieParams The session cookie parameters.
* @property string $cookieMode How to use cookie to store session ID. Defaults to 'Allow'.
* @property integer $gCProbability The probability (percentage) that the gc (garbage collection) process is started on every session initialization, defaults to 1 meaning 1% chance.
* @property float $gCProbability The probability (percentage) that the gc (garbage collection) process is started on every session initialization, defaults to 1 meaning 1% chance.
* @property boolean $useTransparentSessionID Whether transparent sid support is enabled or not, defaults to false.
* @property integer $timeout The number of seconds after which data will be seen as 'garbage' and cleaned up, defaults to 1440 seconds.
* @property CHttpSessionIterator $iterator An iterator for traversing the session variables.
* @property SessionIterator $iterator An iterator for traversing the session variables.
* @property integer $count The number of session variables.
* @property array $keys The list of session variable names.
* @var boolean whether the session should be automatically started when the session application component is initialized, defaults to true.
* @var boolean whether the session should be automatically started when the session component is initialized.
*/
public$autoStart=true;
/**
* Initializes the application component.
* This method is required by IApplicationComponent and is invoked by application.
...
...
@@ -93,7 +94,7 @@ class CHttpSession extends CApplicationComponent implements IteratorAggregate, A
/**
* Returns a value indicating whether to use custom session storage.
* This method should be overriden to return true if custom session storage handler should be used.
* To use custom session storage, override this method and return This method should be overridden to return true if custom session storage handler should be used.
* If returning true, make sure the methods {@link openSession}, {@link closeSession}, {@link readSession},
* {@link writeSession}, {@link destroySession}, and {@link gcSession} are overridden in child
* class, because they will be used as the callback handlers.
...
...
@@ -116,14 +117,14 @@ class CHttpSession extends CApplicationComponent implements IteratorAggregate, A
@session_start();
if(YII_DEBUG&&session_id()==''){
$message=Yii::t('yii|Failed to start session.');
$message=Yii::t('yii','Failed to start session.');
* @param string $value how to use cookie to store session ID. Valid values include 'none', 'allow' and 'only'.
* Sets the value indicating whether cookies should be used to store session IDs.
* Three states are possible:
*
* - true: cookies and only cookies will be used to store session IDs.
* - false: cookies will not be used to store session IDs.
* - null: if possible, cookies will be used to store session IDs; if not, other mechanisms will be used (e.g. GET parameter)
*
* @param boolean|null $value the value indicating whether cookies should be used to store session IDs.
*/
publicfunctionsetCookieMode($value)
publicfunctionsetUseCookies($value)
{
if($value==='none'){
if($value===false){
ini_set('session.use_cookies','0');
ini_set('session.use_only_cookies','0');
}else{
if($value==='allow'){
ini_set('session.use_cookies','1');
ini_set('session.use_only_cookies','0');
}else{
if($value==='only'){
}elseif($value===true){
ini_set('session.use_cookies','1');
ini_set('session.use_only_cookies','1');
}else{
thrownewCException(Yii::t('yii|CHttpSession.cookieMode can only be "none", "allow" or "only".'));
}
}
ini_set('session.use_cookies','1');
ini_set('session.use_only_cookies','0');
}
}
/**
* @return integer the probability (percentage) that the gc (garbage collection) process is started on every session initialization, defaults to 1 meaning 1% chance.
* @return float the probability (percentage) that the GC (garbage collection) process is started on every session initialization, defaults to 1 meaning 1% chance.