Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 23 additions & 25 deletions reference/session/functions/session-gc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,33 @@
<type class="union"><type>int</type><type>false</type></type><methodname>session_gc</methodname>
<void/>
</methodsynopsis>
<para>
<simpara>
By default, PHP uses <link linkend="ini.session.gc-probability">session.gc_probability</link>
to run the session garbage collector probabilistically on each
request. There are some limitations with this approach:
</para>
<para>
<simplelist>
<member>Low traffic sites may not have their session data deleted within the preferred duration.</member>
<member>High traffic sites may have the garbage collector run too frequently, performing unnecessary extra work.</member>
<member>Garbage collection is performed on the user's request, and the user may experience a delay.</member>
</simplelist>
</para>
<para>
</simpara>
<simplelist>
<member>Low traffic sites may not have their session data deleted within the preferred duration.</member>
<member>High traffic sites may have the garbage collector run too frequently, performing unnecessary extra work.</member>
<member>Garbage collection is performed on the user's request, and the user may experience a delay.</member>
</simplelist>
<simpara>
For production systems, it is recommended to disable the
probability-based garbage collection by setting
<link linkend="ini.session.gc-probability">session.gc_probability</link> to 0
<link linkend="ini.session.gc-probability">session.gc_probability</link> to <literal>0</literal>
and explicitly trigger the garbage collector periodically, for example by using "cron" on
UNIX-like systems to run a script that calls <function>session_gc</function>.
</para>
</simpara>

<note>
<para>
<simpara>
When calling <function>session_gc</function> from a command-line php script,
the <link linkend="ini.session.save-path">session.save_path</link> must be set
to the same value as web requests, and the script must have access and delete
permissions for the session files. This may be affected by the user the script runs as,
and container or sandboxing features such as systemd's <literal>PrivateTmp=</literal>
option.
</para>
</simpara>
</note>
</refsect1>

Expand All @@ -50,22 +48,22 @@

<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<simpara>
<function>session_gc</function> returns the number of deleted session
entries on success, &false; for failure.
</para>
entries on success, &return.falseforfailure;.
</simpara>
<note>
<para>
Old session save handlers do not return number of deleted session data, but
rather only a success/failure flag. If this is the case, 1 is returned regardless of
<simpara>
Old session save handlers do not return the number of deleted session entries, but
rather only a success/failure flag. If this is the case, <literal>1</literal> is returned regardless of
how many session entries are actually deleted.
</para>
</simpara>
</note>
</refsect1>

<refsect1 role="examples">
&reftitle.examples;
<para>
<simpara>
<example>
<title><function>session_gc</function> example for task managers like cron</title>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this para tag is actually not needed at all

<programlisting role="php">
Expand Down Expand Up @@ -112,18 +110,18 @@ if (file_exists($gc_time)) {
]]>
</programlisting>
</example>
</para>
</simpara>
</refsect1>

<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simpara>
<simplelist>
<member><function>session_start</function></member>
<member><function>session_destroy</function></member>
<member><link linkend="ini.session.gc-probability">session.gc_probability</link></member>
</simplelist>
</para>
</simpara>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto: the para tag is not actually needed, just have the simplelist directly.

</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Expand Down
Loading