Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95149 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66233 invoked from network); 14 Aug 2016 21:39:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Aug 2016 21:39:56 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@ohgaki.net; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@ohgaki.net; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ohgaki.net designates 180.42.98.130 as permitted sender) X-PHP-List-Original-Sender: yohgaki@ohgaki.net X-Host-Fingerprint: 180.42.98.130 ns1.es-i.jp Received: from [180.42.98.130] ([180.42.98.130:57959] helo=es-i.jp) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 35/13-36656-925E0B75 for ; Sun, 14 Aug 2016 17:39:55 -0400 Received: (qmail 126544 invoked by uid 89); 14 Aug 2016 21:39:50 -0000 Received: from unknown (HELO mail-qk0-f175.google.com) (yohgaki@ohgaki.net@209.85.220.175) by 0 with ESMTPA; 14 Aug 2016 21:39:50 -0000 Received: by mail-qk0-f175.google.com with SMTP id t7so30073879qkh.0 for ; Sun, 14 Aug 2016 14:39:49 -0700 (PDT) X-Gm-Message-State: AEkooutIB+nZqY/IIYUs8KN3vLoQLOhTmW8oG9b88gMubgHzYjALE64CdXWzKv7DANqnqNGMp0NtZq7D0zckxw== X-Received: by 10.55.141.131 with SMTP id p125mr5604942qkd.132.1471210784356; Sun, 14 Aug 2016 14:39:44 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.85.242 with HTTP; Sun, 14 Aug 2016 14:39:03 -0700 (PDT) In-Reply-To: References: Date: Mon, 15 Aug 2016 06:39:03 +0900 X-Gmail-Original-Message-ID: Message-ID: To: Bishop Bettini Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC][VOTE] Add session_gc() function From: yohgaki@ohgaki.net (Yasuo Ohgaki) Hi Bishop! On Sat, Aug 13, 2016 at 4:49 AM, Bishop Bettini wrote: > On Wed, Aug 10, 2016 at 5:30 AM, Yasuo Ohgaki 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