Re: [RFC][VOTE] Add session_gc() function
| From: | Yasuo Ohgaki | Date: | Sun, 14 Aug 2016 21:39:03 +0000 |
| Subject: | Re: [RFC][VOTE] Add session_gc() function | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-95149@lists.php.net to get a copy of this message | ||
Hi Bishop!
On Sat, Aug 13, 2016 at 4:49 AM, Bishop Bettini <bishop@php.net> wrote:
> On Wed, Aug 10, 2016 at 5:30 AM, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote:
>>
>> Hi all,
>>
>> This RFC is to add session_gc() function.
>>
>> session_gc() function is required API for periodic session GC that is
>> best practice for production web sites.
>>
>> https://wiki.php.net/rfc/session-gc
>> It requires 2/3 majority to pass.
>> Vote starts: 2016/08/10 - Vote ends: 2016/08/17 23:59:59 UTC
>
>
> +1.
>
> Should we document a polyfill, since the session GC firing logic can be
> non-intuitive? Here's an attempt, anyhow:
>
> function session_gc() {
> $initial = [
> session_status(),
> ini_get('session.gc_probability'),
> ini_get('session.gc_divisor'),
> ];
> if (PHP_SESSION_DISABLED === $initial[0]) {
> return false;
> }
> if (PHP_SESSION_ACTIVE === $initial[0]) {
> session_write_close();
> }
> ini_set('session.gc_probability', 1);
> ini_set('session.gc_divisor', 1);
> session_start();
> ini_set('session.gc_probability', $initial[1]);
> ini_set('session.gc_divisor', $initial[2]);
> if (PHP_SESSION_NONE === $initial[0]) {
> session_write_close();
> }
> return true;
> }
Thank you for the comment!
I'll add your example code in the manual.
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net