mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 05:37:32 +02:00
Merge pull request #4132 from Deltik/fix-4113
Enable PHP session file garbage collection
This commit is contained in:
@@ -194,8 +194,8 @@ class e_session
|
|||||||
*/
|
*/
|
||||||
public function setDefaultSystemConfig()
|
public function setDefaultSystemConfig()
|
||||||
{
|
{
|
||||||
if(!$this->getSessionId())
|
if ($this->getSessionId()) return $this;
|
||||||
{
|
|
||||||
$config = array(
|
$config = array(
|
||||||
'ValidateRemoteAddr' => (e_SECURITY_LEVEL >= self::SECURITY_LEVEL_BALANCED),
|
'ValidateRemoteAddr' => (e_SECURITY_LEVEL >= self::SECURITY_LEVEL_BALANCED),
|
||||||
'ValidateHttpVia' => (e_SECURITY_LEVEL >= self::SECURITY_LEVEL_HIGH),
|
'ValidateHttpVia' => (e_SECURITY_LEVEL >= self::SECURITY_LEVEL_HIGH),
|
||||||
@@ -241,14 +241,31 @@ class e_session
|
|||||||
ini_set('session.hash_bits_per_character', 5);
|
ini_set('session.hash_bits_per_character', 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->fixSessionFileGarbageCollection();
|
||||||
|
|
||||||
$this->setConfig($config)
|
$this->setConfig($config)
|
||||||
->setOptions($options);
|
->setOptions($options);
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modify PHP ini at runtime to enable session file garbage collection
|
||||||
|
*
|
||||||
|
* Takes no action if the garbage collector is already enabled.
|
||||||
|
*
|
||||||
|
* @see https://github.com/e107inc/e107/issues/4113
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function fixSessionFileGarbageCollection()
|
||||||
|
{
|
||||||
|
$gc_probability = ini_get('session.gc_probability');
|
||||||
|
if ($gc_probability > 0) return;
|
||||||
|
|
||||||
|
ini_set('session.gc_probability', 1);
|
||||||
|
ini_set('session.gc_divisor', 100);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve value from current session namespace
|
* Retrieve value from current session namespace
|
||||||
* Equals to $_SESSION[NAMESPACE][$key]
|
* Equals to $_SESSION[NAMESPACE][$key]
|
||||||
|
Reference in New Issue
Block a user