Add session_gc() View as Markdown

Implemented (PHP 7.1)
Authors
Yasuo Ohgaki, yohgaki@ohgaki.net
Version
1.0
Source
wiki.php.net/rfc/session-gc

Vote

Add session_gc() function closed
Yes
12
No
0
12 voters
bishop Yes 2016-08-12 19:49
cmb Yes 2016-08-17 22:26
colinodell Yes 2016-08-10 13:15
derick Yes 2016-08-15 15:17
diegopires Yes 2016-08-16 18:14
lstrojny Yes 2016-08-12 15:14
mariano Yes 2016-08-16 17:36
mike Yes 2016-08-17 07:04
stas Yes 2016-08-13 19:21
trowski Yes 2016-08-17 18:59
yohgaki Yes 2016-08-10 10:54
yunosh Yes 2016-08-11 08:25

Discussions on the mailing list

[RFC][Discussion] Add session_gc()
by Yasuo Ohgaki · 25 messages
[RFC][VOTE] Add session_gc() function
by Yasuo Ohgaki · 7 messages

RFC text

Copied from wiki.php.net, last synchronized Oct 13, 2026 11:51 UTC

Introduction

Current session GC depends on probability. Thus, low traffic sites would not delete expired session data and could be usable as valid session. Traffic varies day and night time for high traffic sites. Chances are high that expired session may not be deleted as it should.

The best way to purge old session data is executing GC periodically.

Although timestamp based session management is declined twice, it is mandatory for session management. Please refer to Strict Session RFC for details.

Proposal

  • Add session_gc() API.
  • Document calling session_gc() periodically is the best practice.
int session_gc(void)

It simply executes GC save handler defined.

Backward Incompatible Changes

None

Proposed PHP Version(s)

PHP 7.2

Vote

This project requires a 2/3 majority. Vote starts: 2016/08/10 - Vote ends: 2016/08/17 23:59:59 UTC

Vote: Add session_gc() function — Yes: 12 · No: 0 (closed)

Patches and Tests

Implementation

After the project is implemented, this section should contain

  1. the version(s) it was merged to
    1. PHP 7.1 and master branch (Merged to PHP 7.1 also by RM permission)
  2. a link to the git commit(s)
    1. http://git.php.net/?p=php-src.git;a=commitdiff;h=1cf179e4150308d8217d9517408ca5e22b5d607f
  3. a link to the PHP manual entry for the feature
    1. http://svn.php.net/viewvc?view=revision&revision=339955

References