Bug #76368 [NEW]: Garbage collection configuration not handled correctly.
| From: | Alastair dot Growcott at dynautics dot com | Date: | Wed, 23 May 2018 06:54:03 +0000 |
| Subject: | Bug #76368 [NEW]: Garbage collection configuration not handled correctly. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-215335@lists.php.net to get a copy of this message | ||
From: Alastair dot Growcott at dynautics dot com
Operating system: Ubuntu
PHP version: 7.0.30
Package: Session related
Bug Type: Bug
Bug description:Garbage collection configuration not handled correctly.
Description:
------------
The exact version is PHP 7.0.30-0ubuntu0.16.04.1 and is running in a
Docker container for a website. I got the version running the CLI
command though.
My settings are:
session.gc_probability = 0
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
As I understand the documentation, having a probability of 0 means that
garbage collection should never happen. However I am finding my session
is losing all its values after about 30 minutes (I have never measured
it exactly). I increased the gc_maxlifetime value to 144000 and after 5
hours the session was still in existance.
This started happening after a recent rebuild of my Docker container
when I moved from one server to another. It looks as if the meaning of a
gc_probability value of zero has been changed from "never" to "always".
Test script:
---------------
I haven't tested it, but this should reproduce the problem:
<?php
session_name("Demonstration");
$result = session_start(['cookie_lifetime' => 86400]);
if (!$result) {
echo "Failed to start session.";
} else if (isset($_SESSION['test_value'])) {
echo "Bug didn't happen.";
} else {
echo "Starting new session."
}
?>
Create a website with this script and the settings above. Load the page.
Wait about 30 minutes. Load the page again. You can shorten the wait by
reducing session.gc_maxlifetime in the configuration.
Expected result:
----------------
On the first load you should see "Starting new session.". On the second
load after some time you should see "Bug didn't happen.".
Actual result:
--------------
Instead of "Bug didn't happen." you will see "Starting new session." as
the session has been garbage collected.
--
Edit bug report at https://bugs.php.net/bug.php?id=76368&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76368&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76368&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76368&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76368&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76368&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76368&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76368&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76368&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76368&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76368&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76368&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76368&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76368&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76368&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76368&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76368&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76368&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76368&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76368&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76368&r=mysqlcfg