diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-07-01 22:42:41 +0200 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-07-01 22:42:41 +0200 |
commit | 3da427e94bb5f4d0d609cd4b868b2796e5e50a65 (patch) | |
tree | d3a41bb1c8586f4876b6a4b4808d5edbbd1ffe0d | |
parent | 7db0f597c78cd5485b566d9cd6e3935a8489c540 (diff) | |
parent | c254792b02cccebb10993feed58fb9ed63a28ebc (diff) |
Merge pull request #1549 from chrisguiney/session_gc
Allow session garbace collection percentage to be configured.
-rw-r--r-- | system/libraries/Session.php | 11 | ||||
-rw-r--r-- | user_guide_src/source/changelog.rst | 2 |
2 files changed, 5 insertions, 8 deletions
diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 72a942b8a..af38dc366 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -155,12 +155,6 @@ class CI_Session { */ public $time_reference = 'local'; - /** - * Probablity level of garbage collection of old sessions - * - * @var int - */ - public $gc_probability = 5; /** * Session data @@ -940,8 +934,11 @@ class CI_Session { return; } + $probability = ini_get('session.gc_probability'); + $divisor = ini_get('session.gc_divisor'); + srand(time()); - if ((rand() % 100) < $this->gc_probability) + if ((mt_rand(0, $divisor) / $divisor) < $probability) { $expire = $this->now - $this->sess_expiration; diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index d2774ca12..50dab92ac 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -136,7 +136,7 @@ Release Date: Not Released - Added unbuffered_row() method for getting a row without prefetching whole result (consume less memory). - Libraries - + - CI_Session now respects php.ini's session.gc_probability and session.gc_divisor - Added max_filename_increment config setting for Upload library. - CI_Loader::_ci_autoloader() is now a protected method. - Added custom filename to Email::attach() as $this->email->attach($filename, $disposition, $newname). |