"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "framework/web/CHttpSession.php" between
yii-1.1.19.5790cb.tar.gz and yii-1.1.20.6ed384.tar.gz

About: Yii is a high-performance component-based PHP framework for developing large-scale Web applications. Hint: Yii 1.1 is now in maintenance mode.

CHttpSession.php  (yii-1.1.19.5790cb):CHttpSession.php  (yii-1.1.20.6ed384)
skipping to change at line 80 skipping to change at line 80
* @since 1.0 * @since 1.0
*/ */
class CHttpSession extends CApplicationComponent implements IteratorAggregate,Ar rayAccess,Countable class CHttpSession extends CApplicationComponent implements IteratorAggregate,Ar rayAccess,Countable
{ {
/** /**
* @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 application component is initialized, defaults to true.
*/ */
public $autoStart=true; public $autoStart=true;
/** /**
* @var array Frozen session data
* @since 1.1.20
*/
private $_frozenData;
/**
* Initializes the application component. * Initializes the application component.
* This method is required by IApplicationComponent and is invoked by app lication. * This method is required by IApplicationComponent and is invoked by app lication.
*/ */
public function init() public function init()
{ {
parent::init(); parent::init();
if($this->autoStart) if($this->autoStart)
$this->open(); $this->open();
register_shutdown_function(array($this,'close')); register_shutdown_function(array($this,'close'));
skipping to change at line 273 skipping to change at line 279
} }
/** /**
* @param string $value how to use cookie to store session ID. Valid valu es include 'none', 'allow' and 'only'. * @param string $value how to use cookie to store session ID. Valid valu es include 'none', 'allow' and 'only'.
* @throws CException * @throws CException
*/ */
public function setCookieMode($value) public function setCookieMode($value)
{ {
if($value==='none') if($value==='none')
{ {
$this->freeze();
ini_set('session.use_cookies','0'); ini_set('session.use_cookies','0');
ini_set('session.use_only_cookies','0'); ini_set('session.use_only_cookies','0');
$this->unfreeze();
} }
elseif($value==='allow') elseif($value==='allow')
{ {
$this->freeze();
ini_set('session.use_cookies','1'); ini_set('session.use_cookies','1');
ini_set('session.use_only_cookies','0'); ini_set('session.use_only_cookies','0');
$this->unfreeze();
} }
elseif($value==='only') elseif($value==='only')
{ {
$this->freeze();
ini_set('session.use_cookies','1'); ini_set('session.use_cookies','1');
ini_set('session.use_only_cookies','1'); ini_set('session.use_only_cookies','1');
$this->unfreeze();
} }
else else
throw new CException(Yii::t('yii','CHttpSession.cookieMod e can only be "none", "allow" or "only".')); throw new CException(Yii::t('yii','CHttpSession.cookieMod e can only be "none", "allow" or "only".'));
} }
/** /**
* @return float the probability (percentage) that the gc (garbage collec tion) process is started on every session initialization, defaults to 1 meaning 1% chance. * @return float the probability (percentage) that the gc (garbage collec tion) process is started on every session initialization, defaults to 1 meaning 1% chance.
*/ */
public function getGCProbability() public function getGCProbability()
{ {
skipping to change at line 306 skipping to change at line 318
} }
/** /**
* @param float $value the probability (percentage) that the gc (garbage collection) process is started on every session initialization. * @param float $value the probability (percentage) that the gc (garbage collection) process is started on every session initialization.
* @throws CException if the value is beyond [0,100] * @throws CException if the value is beyond [0,100]
*/ */
public function setGCProbability($value) public function setGCProbability($value)
{ {
if($value>=0 && $value<=100) if($value>=0 && $value<=100)
{ {
$this->freeze();
// percent * 21474837 / 2147483647 ≈ percent * 0.01 // percent * 21474837 / 2147483647 ≈ percent * 0.01
ini_set('session.gc_probability',floor($value*21474836.47 )); ini_set('session.gc_probability',floor($value*21474836.47 ));
ini_set('session.gc_divisor',2147483647); ini_set('session.gc_divisor',2147483647);
$this->unfreeze();
} }
else else
throw new CException(Yii::t('yii','CHttpSession.gcProbabi lity "{value}" is invalid. It must be a float between 0 and 100.', throw new CException(Yii::t('yii','CHttpSession.gcProbabi lity "{value}" is invalid. It must be a float between 0 and 100.',
array('{value}'=>$value))); array('{value}'=>$value)));
} }
/** /**
* @return boolean whether transparent sid support is enabled or not, def aults to false. * @return boolean whether transparent sid support is enabled or not, def aults to false.
*/ */
public function getUseTransparentSessionID() public function getUseTransparentSessionID()
skipping to change at line 576 skipping to change at line 590
} }
/** /**
* This method is required by the interface ArrayAccess. * This method is required by the interface ArrayAccess.
* @param mixed $offset the offset to unset element * @param mixed $offset the offset to unset element
*/ */
public function offsetUnset($offset) public function offsetUnset($offset)
{ {
unset($_SESSION[$offset]); unset($_SESSION[$offset]);
} }
/**
* If session is started we cannot edit session ini settings.
* This function save session data to temporary variable and stop session
.
*
* @see CHttpSession::unfreeze();
* @since 1.1.20
*/
protected function freeze()
{
if (isset($_SESSION) && $this->getIsStarted())
{
$this->_frozenData = $_SESSION;
$this->close();
}
}
/**
* Start session and restore data from temporary variable
*
* @see CHttpSession::freeze();
* @since 1.1.20
*/
protected function unfreeze()
{
if ($this->_frozenData !== null)
{
@session_start();
$_SESSION = $this->_frozenData;
$this->_frozenData = null;
}
}
/**
* Set cache limiter
*
* @param string $cacheLimiter
* @since 1.1.20
*/
public function setCacheLimiter($cacheLimiter)
{
$this->freeze();
session_cache_limiter($cacheLimiter);
$this->unfreeze();
}
} }
 End of changes. 10 change blocks. 
0 lines changed or deleted 60 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)