note 129902 added to function.session-gc
| From: | i.carvallo@gmail.com | Date: | Fri, 06 Dec 2024 21:12:51 +0000 |
| Subject: | note 129902 added to function.session-gc | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221705@lists.php.net to get a copy of this message | ||
Do not use:
if (session_gc() == false)
OR
if (!session_gc())
to evaluate if the garbage collector was triggered successfully since it also returns how many
sessions it deleted, which can be 0 (and that evaluates to false with loose operators).
Sounds dumb, but it's a pitfall i fell into and it generated some confusion. Instead, use
strict operator "===":
if (session_gc() === false)
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 2800:a4:7f7:bb00:8958:2f63:ddf4:55d5)
----
Manual Page -- https://php.net/manual/en/function.session-gc.php
Edit -- https://main.php.net/note/edit/129902
Del: integrated -- https://main.php.net/note/delete/129902/integrated
Del: useless -- https://main.php.net/note/delete/129902/useless
Del: bad code -- https://main.php.net/note/delete/129902/bad+code
Del: spam -- https://main.php.net/note/delete/129902/spam
Del: non-english -- https://main.php.net/note/delete/129902/non-english
Del: in docs -- https://main.php.net/note/delete/129902/in+docs
Del: other reasons-- https://main.php.net/note/delete/129902
Reject -- https://main.php.net/note/reject/129902
Search -- https://main.php.net/manage/user-notes.php